Advertisement
Guest User

Untitled

a guest
Apr 18th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. dbConn = pymssql.connect(server=mssql_server, user=mssql_user, password=mssql_pass, database=mssql_db)
  2. cursor = dbConn.cursor()
  3.  
  4. date = data[0:6]
  5. time = data[7:11]
  6. duration = data[12:16]
  7.  
  8. mssql_output_raw = "('%s','%s','%s');" % (date, time, duration)
  9. mssql_output = mssql_output_raw.replace(" ", "") # Remove any whitespace
  10.  
  11. # Write to MSSQL table
  12. try:
  13. query = "INSERT INTO %s VALUES %s" % (mssql_table, mssql_output)
  14. cursor.execute( query )
  15. dbConn.commit()
  16. except pymssql.OperationalError as e:
  17. logmsg("pymssql.OperationalError exception caught: %s" % str(e).replace("n", " ") )
  18. except:
  19. pass
  20.  
  21. 20019,
  22. 'DB-Lib error message 20019, severity 7:
  23. Attempt to initiate a new Adaptive Server operation with results pending
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement