Tkinter Combobox options taken from MySQL, SQLite database table, CSV file and Json string



Tkinter Combobox options taken from MySQL, SQLite database table, CSV file and Json string

Tkinter Combobox options taken from MySQL, SQLite database table, CSV file and Json string

00:48 Json string as source
04:05 CSV file as source
07:47 MySQL database table as source
14:17 SQLite database table as source

https://youtu.be/Tbkhw4LZpcc Part I Details Tkinter Combobbox
https://youtu.be/Zc4oMkFwRvw Part III Two interlinked dropdown list

We can source options of a Tkinter Combobox from Database tables , CSV or from JSon String.
We will connect to MySQL database and create the connection object, this connection object is the only difference between MySQL and SQLite script and rest of the code is common.
In our student table we will collect unique student classes and use them as options of student table.
query=”SELECT distinct(class) as class FROM student”

We will get sqlalchemy result set with data by using the above query. We will convert this result set to a list as we are planning to use as options of OptionMenu.
my_data=engine.execute(query)

Using this result set of SQLalchem we will create one list
my_list = [r for r, in my_data]
We will use the my_list as values option for the combobox.
For Using SQLite Database In above code only the connection part will be changed.
We can use JSON string and use the name part to populate the options
Similarly one CSV file data can be used to create options for the Combobox

Sample Json Data
https://www.plus2net.com/php_tutorial/student.json
Sample SQL code to create student table
https://www.plus2net.com/sql_tutorial/sql_student_dump.php
Sample CSV file with student data
https://www.plus2net.com/python/download/student.csv

Create SQLite database or download the database file from here
https://www.plus2net.com/python/sqlite-connection.php#create_db

#OptionsfromMySQL #optionsfromSQLITE #optionsCSV #optionsJSON #tkinter #combobox #python #plus2net #GUI #tkinter

Comments are closed.