0

I have 3 dbs in Azure which I tried connecting to one of them.

conn = pymssql.connect(server='hostname.database.windows.net',
                  user='username@hostname',
                  password='*****',
                  database='my_db',
                  timeout=0,
                  login_timeout=60,
                  charset='UTF-8',
                  as_dict=False,
                  host='',
                  port='1433')


cursor = conn.cursor()
cursor.execute('select db_name()')  #to get the name of my db (which should be "my_db")
result = cursor.fetchone()
print result

But what I've got is "master" which is default Azure database. This shouldn't happen because I've already specify 'databse' string argument to "my_db".

Please advice.

1 Answer 1

1

Your problem is your version of pymssql. The latest version on pip is 2.1.0, but the version that supports azure is 2.1.1. So, if you install it from source, it will work. Also, make sure you have freeTDS > 0.91

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

2 Comments

You may want to elaborate on why freeTDS is an additional requirement. Otherwise, welcome to SO
pymssql is a python interface to freetds.

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.