-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetRoom.py
30 lines (21 loc) · 900 Bytes
/
getRoom.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import pyodbc
from datetime import date
ngay_hien_tai = date.today()
# server = 'NGUYENTIENDAT'
# database = 'ProJect_StartUP'
# table='Phong
def getRoom(server,database,table):
l=[]
# username = 'your_username'
# password = 'your_password'
# Tạo kết nối
#connection = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER=' + server + ';DATABASE=' + database) #+ ';UID=' + username + ';PWD=' + password)
connection = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER=' + server + ';DATABASE=' + database + ';Trusted_Connection=yes;')
cursor = connection.cursor()
cursor.execute(f"SELECT MAPHONG, NGAY FROM {table} WHERE NGAY = '{ngay_hien_tai}'")
for row in cursor:
l.append(row)
cleaned_data = [(item[0], item[1].strftime('%Y-%m-%d')) for item in l]
return cleaned_data
if '__name__'=='__main__':
getRoom()