Connect to SQL Server DB with Active Directory Universal Authentication using Python -


first, i'm not developer apologize if redundant or unhelpful question.

in microsoft sql server management studio, able connect server using active directory universal authentication, can't figure out way using python.

when login application, after click connect, azure login screen pops up, , able login username: myname@domain.com , password.

however, when try connect using pyodbc following code, error below:

import pyodbc  def main():     servername = "name.database.windows.net"     dbname = "databasename"      connection = pyodbc.connect("driver={sql server};server=" + servername +                   ";database=" + dbname +                   ";uid=myname@domain.com;pwd=mypassword")     cursor = connection.cursor()     data = cursor.execute("select * sometable;")     alldata = data.fetchall()     connection.close()     in alldata:         print(i)  if __name__== "__main__":     main() 

pyodbc.programmingerror: ('42000', "[42000] [microsoft][odbc sql server driver][sql server]cannot open server 'domain' requested login. client ip address 'xx.xx.xx.xx' not allowed access server. enable access, use windows azure management portal or run sp_set_firewall_rule on master database create firewall rule ip address or address range. may take 5 minutes change take effect. (40615) (sqldriverconnect); [42000] [microsoft][odbc sql server driver][sql server]

i know there have been posts similar issues, not sure same problem. have use active directory universal authentication server. have tried of sql server drivers return pyodbc.drivers() no luck. using same ip address login through sql server management studio when attempting through python program. there different module can use login azure, or impossible do?

for reference, popups see when login through microsoft sql server management studio below. have been stuck on while, appreciated. enter image description here

enter image description here

i same error message if have not set azure sql firewall: enter image description here

we can via azure portal set sql server firewall, this: enter image description here

after add firewall settings, can use python script query, python script works me.


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -