Skip to content

Instantly share code, notes, and snippets.

@jamescalam
Created February 22, 2020 19:27
Show Gist options
  • Save jamescalam/9f6249ae0aaae2753232ceca2d68aec3 to your computer and use it in GitHub Desktop.
Save jamescalam/9f6249ae0aaae2753232ceca2d68aec3 to your computer and use it in GitHub Desktop.
import pyodbc
from datetime import datetime
class Sql:
def __init__(self, database, server="XXVIR00012,55000"):
# here we are telling python what to connect to (our SQL Server)
self.cnxn = pyodbc.connect("Driver={SQL Server Native Client 11.0};"
"Server="+server+";"
"Database="+database+";"
"Trusted_Connection=yes;")
# initialise query attribute
self.query = "-- {}\n\n-- Made in Python".format(datetime.now()
.strftime("%d/%m/%Y"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment