(Jun-04-2020, 09:00 AM)buran Wrote: Maybe unnecessary question, but do you instantiate the class?I'm using it with socket so server.py takes takes the DataBase class and instantiates it. That's when the init fires and the endless wait happens.
(Jun-04-2020, 09:00 AM)buran Wrote: Also, not related to your question, but I don't think if table not in cursor: would work as you expect. Not to mention tables are not defined (or are defined globally?)
tables
is a list that I had defined before the class, I didn't include it in the code in the original question, but here it is below if you would like to see it.tables = { "Users": ['id INT AUTO_INCREMENT PRIMARY KEY', 'username VARCHAR(20)', 'password VARCHAR(20)', 'dateJoined DATETIME', 'lastUsedMacAddress VARCHAR(17)', 'lastLog DATETIME'] }I was thinking that the
"SHOW TABLES"
command will return each table as a string of it's name inside of a list as the value of cursor, well that's what I got from reading through the info here https://www.w3schools.com/python/python_..._table.asp. Is that not the case?I just realized the for loop will have to change to this
for table in cursor: if table[0] not in tables: self.cursor.execute("CREATE TABLE %s (%s)" % (table, ", ".join(tables[table])))