I have two questions:
QUESTION-1:
Suppose I have two .py File-1 and File-2
File-1 contains the following statements:
try:
cononnection = pypyodbc.connect('DRIVER={SQL Server};'
'SERVER=........'
'DATABASE=......'
'UID=......;PWD=......')
except:
print("I am unable to connect to the SQL SERVER Database")
In File-2, if I use the connection defined in File-1 in the following way:
import AnotherPythonFile as File1
def query():
conxn1 = File1.cononnection
conxn2 = File1.cononnection
...
...
Will conxn1 and conxn2 use the same connection opened in File-1 or they will open two more new connections?
QUESTION-2:
If a 'pypyodbc.DatabaseError' occurs while executing the following statements, then will the connection close automatically (due to the error)?
cursr = connection.cursor()
cursr.execute(queryStr)