Python Forum
[mysql.connector] The database is never connected to and there are no errors
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[mysql.connector] The database is never connected to and there are no errors
#3
(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])))
Reply


Messages In This Thread
RE: [mysql.connector] The database is never connected to and there are no errors - by SheeppOSU - Jun-04-2020, 05:41 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Display name of a pc connected over lan fatopeo 1 1,453 Mar-16-2022, 10:10 AM
Last Post: Gribouillis
  mysql connector/telnet issue (re: text game) rebubula76 1 2,583 Feb-06-2018, 08:00 PM
Last Post: rebubula76

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020