I have run into a very strange issue where my code below was working (I was able to add a table into the DB). After dropping a test table via the mysql workbench I am able to add a database and the code continues to run with no errors but no table is added. I have slimmed the SQL right down and attempted on different dbs. I have also restarted. Am I doing something wrong here? Any help is greatly appreciated.
import mysql.connector
import os
dirname = os.path.abspath('')
sql_filename = dirname + '\SQL_Creation\Test.sql'
class connectionsetup:
def __init__(self):
self.mydb = mysql.connector.connect(
host="localhost",
user="root",
password="")
try:
self.mycursor = self.mydb.cursor()
print('Conneciton Succesful')
self.mycursor.execute("CREATE DATABASE AP_Application_Db_test")
print('Database Created')
self.mycursor.execute('USE ap_application_db_test; Create TABLE test (SERIAL_NUMBER VARCHAR(255),VIOLATION_STATUS VARCHAR(255))', multi=True)
self.mydb.commit()
self.mydb.close()
except mysql.connector.Error as err:
print(err)
print("Error Code:", err.errno)
print("SQLSTATE", err.sqlstate)
print("Message", err.msg )
connectionsetup()