question

123rai456-3405 avatar image
0 Votes"
123rai456-3405 asked ·

Connection time

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
· 1
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @123rai456-3405, just wanted to follow up on this thread. Please let us know if you have any follow up query or else you can mark the answer as 'Accept Answer'.

0 Votes 0 ·

1 Answer

AnuragSharma-MSFT avatar image
0 Votes"
AnuragSharma-MSFT answered ·

Hi @123rai456-3405, 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'







image.png (4.8 KiB)
image.png (4.5 KiB)
·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.