This is simply just inserting a new row of data in one of my tables. I'm thinking about leaving this(db connection) in it's own py file. My main gui file will call on it for the db connection and functions/sql statements.
import pyodbc def databaseConnection(driver, server, database, user, pwd): connectionString = f"DRIVER={driver};SERVER={server};PORT=1433;DATABASE={database};UID={user};PWD={pwd}" conn = pyodbc.connect(connectionString) sqlCMD = conn.cursor() sqlCMD.execute('SELECT * FROM inventoryDatabase.dbo.Hardware') sqlCMD.execute(''' INSERT INTO inventoryDatabase.dbo.Hardware(serialNumber, modelName, userName, machineActive) VALUES ('B69745', 'L7410', 'BWILSON', 'False') ''') conn.commit() def start(): azureServer = "pythonserver5874.database.windows.net" azureDB = "inventoryDatabase" userName = "lol" password = "lol" driver = "{ODBC Driver 17 for SQL Server}" databaseConnection(driver, azureServer, azureDB, userName, password) if __name__ == '__main__': start()