Skip to content

Instantly share code, notes, and snippets.

@jamescalam
Created February 22, 2020 22:02
Show Gist options
  • Save jamescalam/300d5f1e38159122f0aca6a9d129ec78 to your computer and use it in GitHub Desktop.
Save jamescalam/300d5f1e38159122f0aca6a9d129ec78 to your computer and use it in GitHub Desktop.
def manual(self, query, response=False):
cursor = self.cnxn.cursor() # create execution cursor
if response:
return read_sql(query, self.cnxn) # get sql query output to dataframe
try:
cursor.execute(query) # execute
except pyodbc.ProgrammingError as error:
print("Warning:\n{}".format(error)) # print error as a warning
self.cnxn.commit() # commit query to SQL Server
return "Query complete."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment