Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 9e82ea4

Browse files
committed
moving connection handling inside class
1 parent 3266fbb commit 9e82ea4

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

app.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@
1313
parser = reqparse.RequestParser()
1414
parser.add_argument('customer')
1515

16-
# Create connection to Azure SQL
17-
conn = pyodbc.connect(os.environ['SQLAZURECONNSTR_WWIF'])
16+
# Store connection string
17+
conn_str = os.environ['SQLAZURECONNSTR_WWIF']
1818

1919
class Queryable(Resource):
2020
def executeQueryJson(self, verb, payload=None):
2121
result = {}
22+
conn = pyodbc.connect(conn_str)
2223
cursor = conn.cursor()
2324
entity = type(self).__name__.lower()
2425
procedure = f"web.{verb}_{entity}"

requirements.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
pyodbc
22
flask
3-
flask-restful
3+
flask-restful
4+
applicationinsights

0 commit comments

Comments
 (0)