1

I have numerous databases on a server,I am able to connect using : engine = create_engine("mssql+pyodbc://scott:tiger@some_dsn"). However, this connects to the default database. Is there a way i can specify a particular Database on the server? I tried :engine = create_engine("mssql+pyodbc://scott:tiger@some_dsn/bdname") but this did not work

Regards

1 Answer 1

3

Refer to doc:

engine = create_engine('mssql+pymssql://scott:tiger@hostname:port/dbname')
Sign up to request clarification or add additional context in comments.

3 Comments

thanks Tiny. but your solution is via pymssql is there no way to do this with pyodbc?
Hi Tiny, please what would the host name and port be when using pymssql? i am failry new to this.many thanks
the host name is the db's host ( server name where your db is hosted), you can try with this link to check your port number mssqltips.com/sqlservertip/2495/…

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.