-
Notifications
You must be signed in to change notification settings - Fork 0
/
SqlCheckConnect.py
40 lines (29 loc) · 938 Bytes
/
SqlCheckConnect.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
30
31
32
33
34
35
36
37
38
39
40
import tkinter as tk
import pandas as pd
from sqlalchemy import create_engine
import pyodbc
svr_name = 'sql1'
db_name = 'QLSV'
u_name = 'as'
u_password = '123456a@'
try:
connectSever = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server}' +
';SERVER=' + 'localhost, 1433' +
# ';Database= QLSV' +
';UID=' + 'sa' +
';PWD=' + '123456a@;'+
'Authentication type = SQL Login;')
print("connection successfull")
except NameError:
print ("connection failed")
print('accept connect')
cursor = connectSever.cursor()
cursor.execute('USE QLSV')
cursor.execute('SELECT * FROM SinhVien')
for row in cursor:
print('row = %r\n' % (row,))
cursor.execute('SP_COLUMNS MONHOC')
list_Column = []
for row in cursor:
list_Column.append(row)
print(list_Column)