1

I have mssql in my windows host machine, and ubuntu in VMware. I try to connect this mssql from virtual machine with pyodbc module in python.

import pyodbc

server = '192.168.0.19'//host ip
database = 'mytestdb'
username = 'sa'
port = "1433"
password = 'mypassword'
cnxn = pyodbc.connect('DRIVER={ODBC Driver 13 for SQL Server};SERVER='+server+';PORT='+port+';DATABASE='+database+';UID='+username+';PWD='+ password)
cursor = cnxn.cursor()

remote connection to my mssql instance is already enabled and I can login using same credentials so what might be problem here?

1 Answer 1

2

Try SERVER and PORT in one variable like this: server = '192.168.0.19, 1433' and remove PORT.

If that doesn't work, try {SQL Server} in DRIVER.

Not the answer you're looking for? Browse other questions tagged or ask your own question.