1

I am trying to connect one of my remote database using odbc driver which is configured using DSN. But I did not find related parameters to create_engine object.

Can anyone help on this?

2 Answers 2

1

For SQL Server:

You need to first create a DSN object to use. Go to Start»Settings»Control Panel»Administrative Tools»Data Sources

Open System DSN and add a new DSN. It will give you a list of databases for which you can create a DSN. Select one and and proceed with the steps. Give a name to the DSN (by which you will refer to it later) and the database server name to which you want to connect to. Click here for more detailed steps.

SQL Alchemy

For using this DSN you created with your program you need to use the following steps:

engine = sa.create_engine('mssql+pyodbc://SQLTEST')
saconn = engine.connect()

Now you have the engine object saconn. This can be used for performing your queries on the database.

Hope it helped.

Sign up to request clarification or add additional context in comments.

Comments

0

I have found the classic "//DSNSTRING" method didn't work with SQL Server. From my environment (Python + MSSQL); the below worked:

engine = create_engine("mssql+pyodbc://user:password@DSNSTRING") 

Hope that helps

🤓

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.