Reputation: 41
I keep getting the error "Database.db_search(search) NameError: name 'Database' is not defined".
If anybody could help me I would really appreciate it, I am also new to Stack Overflow so I apologize for any errors I may have made in regards to the overall layout of asking a question.
Thanks.
Database File:
from Staff import *
def db_search(self):
query = "SELECT * FROM customer_information WHERE Last_Name = %s"
cursor.execute(query, (last_name,))
for (Last_Name) in cursor:
print(Last_Name)
return last_name
Staff File:
from Database import *
def gett():
search = search_entry.get()
Database.db_search(search)`
Upvotes: 1
Views: 5935
Reputation: 2293
By using
from Database import *
You've just imported all the contents of Database
, so to get the thing to work you would now just need to call
db_search(search)
from module import *
isn't really a recommended pattern, as you end up rather polluting your namespace (possibility of confusion between methods from different packages).
So if you change your import line to just:
import Database
then your code will work fine.
Upvotes: 1