Xour Xour - 1 year ago 111
Python Question

Cannot connect to SQL\Express with pyodbc/pymssql and Robot Framework

I'm having issues connecting to a working SQL\Express database instance using Robot Framework's DatabaseLibrary.

If I use either

Connect To Database
with previously defined variables or
Connect To Database Using Custom Params
with a connection string, I get the following results:

  • pyodbc:
    ('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)')

  • pymssql::
    InterfaceError: Connection to the database failed for an unknown reason.

The connection string I'm using is the following:
'DRIVER={SQL Server};SERVER=localhost\SQLExpress;UID=sa;PWD=mypass;DATABASE=MyDb'

I copied several examples from guides and tutorials and all of them yield the same result, so my guess is that there is something wrong on my end, but I just can't figure out what. I can access the database using the Microsoft SQL Server Management Studio just fine, so the database is running.

Any guidance will be greatly appreciated!

Answer Source

I was able to connect using @Goralight approach: Connect To Database Using Custom Params pymssql ${DBConnect} where ${DBConnect} contained database, user, Password, host and port

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download