Connection time

123rai456 46 Reputation points
2021-03-18T08:58:48.367+00:00

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
    2021-03-19T05:28:33.763+00:00

    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:

    79379-image.png

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

    79380-image.png

    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