Hello
I am trying to make a SQL Express .BAK file of an SDE using the PYODBC in pywin32.
I have the sample code (below), but am not too sure if I have it set-up correctly. Could anyone explain the parameters in an example? Specifically the connection parameters.
When I run the script that I have so far, I am getting an error about SQL. Any help will be appreciated.
Ben
Error: ('08001', '[08001] [Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied. (17) (SQLDriverConnect); [01000] [Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionOpen (Connect()). (53)')
Sample Code that I used from another post:
- import pyodbc
-
- conn = pyodbc.connect('DRIVER={SQL Server};SERVER= <server name>;UID=sa;PWD=sa;Trusted_Connection=yes', autocommit=True)
- backup_path = 'C:\\temp\\'
- db = "VECTOR"
-
- def backup_db(conn, db, backup_path):
- cur = conn.cursor()
- try:
- cur.execute('BACKUP DATABASE ? TO DISK=?', [db, backup_path + db + r'.bak'])
- while cur.nextset():
- pass
- cur.close()
- except:
- print 'Unable to backup: ' + db
-
- backup_db(conn, db, backup_path)
-
- conn.close()