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:
Is the sample code above what you used to create your code or is it your code? If the former, please post your code. If the latter, start by replacing <server name> with an actual SQL Server instance name. Also, is your password for the sa user really 'sa'?
Hello. This is what I have below with the PW altered. I was unsure about how to enter the server name. I tried mcgis_sqlmcgis, sqlmcgis, mcgis\sqlmcgis, mcgis
sqlmcgis. Thanks
import pyodbc
conn = pyodbc.connect('DRIVER={SQL Server};SERVER= mcgis\sqlmcgis ;UID=sa;PWD=trailertrash;Trusted_Connection=yes', autocommit=True)
backup_path = 'C:
Backups-GIS-ToExternal
'
db = "RWSA_GIS"
def backup_db(conn, db, backup_path):
cur = conn.cursor()
try:
cur.execute('BACKUP DATABASE ? TO DISK=?', )
while cur.nextset():
pass
cur.close()
except:
print 'Unable to backup: ' + db
backup_db(conn, db, backup_path)
conn.close()
OK, a few comments:
Thank you very much. Your suggestion about the SQL driver seemed to be the key to this problem.
Cheers
Ben