Connection time

123rai456 46 Reputation points

How much time it takes to connect Azure SQL database using pyodbc. now = time.time() cnxn: pyodbc.Connection = pyodbc.connect(connection_string) crsr: pyodbc.Cursor = cnxn.cursor() time1 = time.time()-now it's coming around 3.5 seconds for me. What can be the reason for it to take that much time. Does it normally take this much time?

Azure SQL Database
{count} votes

Accepted answer
  1. Anurag Sharma 17,586 Reputation points

    Hi @123rai456 , welcome to Microsoft Q&A forum.

    There are multiple factors that influence the time to connect to server like which region are we connecting to, proximity of those regions with respect to the application from which we are connecting it from, application is deployed locally on system or on Azure, bandwidth of network etc.

    I have done a basic test of connecting a local app with Azure SQL Database in 2 regions.

    One was to East US region which is far from my local working area (India) and I observed the same connect time of approx. 3 seconds:


    Second was in region in central India which only took less than a second to connect to:


    Again this is when I was trying to connect to Azure SQL from my local app. If I deploy my application to Azure in same region as my Azure SQL Database is, this time will further reduce to a significant value.

    Please let us know if this helps or else we can discuss further.


    If answer helps, please mark it as 'Accept Answer'

    0 comments No comments

0 additional answers

Sort by: Most helpful