0

I have been trying to connect to SQL Server from Flask but with no luck.

I can connect to DB when i try in my Local Machine and it works perfectly fine, but when i try to connect from VM/Remote Desktop, i see the below error.

I have spent lot of time trying to figure out the issue and for solution, but no luck. I suspect something should be with firewalls or security.

Thanks in Advance for help.

conn = pyodbc.connect('Driver={SQL Server};'
        'Server=DEV001;'
        'Database=ZXCZ;'
        'user=gendb;'
        'Password=qwe123;')
OperationalError: ('08001', '[08001] [Microsoft][ODBC SQL Server Driver]
[DBNETLIB]SSL Security error (18) (SQLDriverConnect); 
[08001] [Microsoft][ODBC SQL Server Driver]
[DBNETLIB]ConnectionOpen (SECCreateCredentials()). (1); 
[08001] [Microsoft][ODBC SQL Server Driver]Invalid connection string attribute (0)')
4
  • Are you sure {SQL Server} is the right driver? github.com/mkleehammer/pyodbc/wiki/… Commented Feb 19, 2020 at 15:00
  • {SQL Server} worked fine when i try in my Local Machine, but i see issues only when i try in Virtual Machine. Commented Feb 19, 2020 at 15:15
  • Be sure to use appropriate ODBC parameters. Use uid and pwd instead of user and password. Also, remember a virtual machine is different environment than local machine. It must have network or remote access to database and installed ODBC drivers. Commented Feb 19, 2020 at 15:33
  • The VM could have different drivers to your local machine... Commented Feb 19, 2020 at 17:26

1 Answer 1

2

Make sure you use the latest version of ODBC, that you can find here:

https://learn.microsoft.com/en-us/sql/connect/odbc/download-odbc-driver-for-sql-server

At the bottom of the page you'll also find a link to Installation document, in case you're installing in on something different than Windows.

Also, the connection string should look like

DRIVER={ODBC Driver 17 for SQL Server};SERVER=;DATABASE=;UID=;PWD=;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.