import pyodbc
cnxn = pyodbc.connect('DRIVER={SQL Server};' +
'SERVER=' + data.dbConnection()[0] + ';' +
'DATABASE=' + data.dbConnection()[3] + ';' +
'UID=' + data.dbConnection()[1] + ';' +
'PWD=' + data.dbConnection()[2])
cursor = cnxn.cursor()
cursor.execute(
"""
CREATE TABLE Persons
(
P_Id int,
LastName varchar(255),
FirstName varchar(255),
Address varchar(255),
City varchar(255)
)
"""
)
cursor.close()
cnxn.close()
The above code successfully connects to the database. The script also returns no errors when run, however when I go to check if the table was created, there are no tables in the SQL DB at all.
Why is no table created and why is no error returned?