-
Notifications
You must be signed in to change notification settings - Fork 1
/
database_test.py
22 lines (15 loc) · 967 Bytes
/
database_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import pyodbc
from secrets import database, server, username, password
def get_dogs():
cnxn = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER='+server+';DATABASE='+database+';UID='+username+';PWD='+ password)
cursor = cnxn.cursor()
cursor.execute('SELECT * FROM Dogs')
return [row for row in cursor]
# conn_string = """Driver={ODBC Driver for SQL Server 17};Server=tcp:dogchatserver.database.windows.net,1433;Initial Catalog=dogchat;Persist Security Info=False;User ID=dogchatadmin;Password=R0ver123$;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"""
# conn = pyodbc.connect(conn_string)
# # conn = pyodbc.connect('Driver={SQL Server};'
# # 'Server=dogchatserver.database.windows.net;'
# # 'Database=dogchat;'
# # 'Password=R0ver123$;'
# # 'Trusted_Connection=yes;')
# cursor = conn.cursor()