kind of done. there is a mssql ML session, but not relevant right now
This commit is contained in:
@@ -1,23 +1,45 @@
|
||||
import tkinter
|
||||
import pyodbc
|
||||
import csv
|
||||
|
||||
try:
|
||||
connection = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER=.;DATABASE=SampleDB;Trusted_Connection=yes')
|
||||
sql_server_ver = "Not Available"
|
||||
|
||||
cursor = connection.cursor()
|
||||
root = tkinter.Tk()
|
||||
root.geometry("600x400")
|
||||
root.title("Sample Python GUI App")
|
||||
|
||||
label_hello_world = tkinter.Label(root, text=str(sql_server_ver), fg="red")
|
||||
|
||||
def sql_server_version():
|
||||
|
||||
try:
|
||||
connection = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER=.;DATABASE=SampleDB;Trusted_Connection=yes')
|
||||
|
||||
cursor = connection.cursor()
|
||||
|
||||
cursor.execute("select @@VERSION as version")
|
||||
|
||||
while 1:
|
||||
row = cursor.fetchone()
|
||||
if not row:
|
||||
break
|
||||
sql_server_ver = row.version
|
||||
|
||||
cursor.close()
|
||||
connection.close()
|
||||
|
||||
except pyodbc.Error as ex:
|
||||
print()
|
||||
print("exception: ",ex)
|
||||
cursor.close()
|
||||
connection.close()
|
||||
print()
|
||||
exit()
|
||||
|
||||
label_hello_world.config(text=str(sql_server_ver))
|
||||
label_hello_world.pack()
|
||||
|
||||
btn_sql_server_version = tkinter.Button(root, command=sql_server_version, text="Retrieve SQL Server Version")
|
||||
btn_sql_server_version.pack(side=tkinter.TOP, pady=50)
|
||||
|
||||
|
||||
|
||||
|
||||
cursor.close()
|
||||
connection.close()
|
||||
|
||||
except pyodbc.Error as ex:
|
||||
print()
|
||||
print("exception: ",ex)
|
||||
cursor.close()
|
||||
connection.close()
|
||||
print()
|
||||
exit()
|
||||
|
||||
print()
|
||||
root.mainloop()
|
||||
|
||||
Reference in New Issue
Block a user