Hey
I got a few python scripts in the same folder. They all use a SQL connection.
But I have the configured in each of the script files.
Can I somehow include the connection info from a single file. So I only need to update the info their if needed?
Thanks
I got a few python scripts in the same folder. They all use a SQL connection.
But I have the configured in each of the script files.
Can I somehow include the connection info from a single file. So I only need to update the info their if needed?
Thanks
import pyodbc //to seperate file start server = 'tcp:ip' database = 'db' username = 'user' password = 'pass' cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER='+server+';DATABASE='+database+';UID='+username+';PWD='+ password) cursor = cnxn.cursor() //to seperate file end cursor.execute("SELECT TOP 1 field FROM dbo.table") row = cursor.fetchone() while row: print(row[0]) row = cursor.fetchone()