0

I am using Apache Superset and to connect to the SQLServer, I am using the below url which works fine but connects to master DB on MSSQL. I wanted to connect to another DB on MSSQL but do not know how to do that

mssql+pymssql://<username>:<password>@<freetds_name>/?charset=utf8

Is there a way I can explicitly mention the DB name in the url ? Another issue I have is my db name has space in it, it is "Data Analytics"

deejay217
  • 109
  • 2
  • 10

2 Answers2

1

Try

mssql+pymssql://user:pass@host/db

Reference: http://docs.sqlalchemy.org/en/latest/dialects/mssql.html

Nicola Ben
  • 10,615
  • 8
  • 41
  • 65
0

I was not able to find the required parameter where I can just mention the name of the DB in url. Although there are ways of doing it but if you are using freetds_name, I have not see any option of setting DB name. I tried setting default Database name in odbc.ini but for some reason it did not work.

The easiest way is to execute any of the below SQL

EXEC '<Login_name in Quotes>', '<DB name in Quotes>'

OR

ALTER LOGIN <Login_Name_noQuotes> with DEFAULT_DATABASE = <DB_name_no_quotes

Since my DB name had space in it, I implemented the first statement and it worked.

You can check the Default DB by executing below SQL

select name, loginname, dbname as DefaultDB from syslogins

deejay217
  • 109
  • 2
  • 10