import sqlite3
my_conn = sqlite3.connect('my_db.db')
from sqlalchemy import create_engine,text
#my_conn=create_engine("sqlite:////content/drive/MyDrive/db/my_db.db")
my_conn = create_engine("sqlite:///D:\\testing\\my_db\\my_db.db")
my_conn = my_conn.connect() # connection object
In windows system, the absolute path is used in above code.| Display | Paging : Breaking of number of records to pages |
| Delete | Delete record on button click and after user confirmation |
| record display | Return details of the record by entering row ID |
| record add | Insert user entered data through Tkinter window to SQLite table |
| OptionMenu | Unique data from SQLite as OptionMenu list |
| Two OptionMenus | Two dependant OptionMenus ( Category and subcategory) |
| Blob Column | Managing Blob column, changes required in Script managing MySQL database |
| SQLite Connector | Application to Manage Database and create new database |
| Data Entry | GUI to enter data to SQLite and display the same in Treeview |
| Quiz | Storing questions, marks and student details for Quiz application using SQLite database |
r_set=my_conn.execute(text('''SELECT * from student LIMIT 0,10'''));
i=0 # row value inside the loop
for student in r_set:
for j in range(len(student)):
e = Entry(my_w, width=10, fg='blue')
e.grid(row=i, column=j)
e.insert(END, student[j])
i=i+1
This will print 10 rows of records from student table.
import sqlite3
my_conn = sqlite3.connect('my_db.db')
###### end of connection ####
##### tkinter window ######
import tkinter as tk
from tkinter import *
my_w = tk.Tk()
my_w.geometry("400x250")
r_set=my_conn.execute('''SELECT * from student LIMIT 0,10''');
i=0 # row value inside the loop
for student in r_set:
for j in range(len(student)):
e = Entry(my_w, width=10, fg='blue')
e.grid(row=i, column=j)
e.insert(END, student[j])
i=i+1
my_w.mainloop()
import tkinter as tk
from tkinter import *
from sqlalchemy import create_engine,text
my_w = tk.Tk()
my_w.geometry("400x250")
my_conn = create_engine("sqlite:///D:\\testing\\my_db\\my_db.db")
my_conn = my_conn.connect() # connection object
r_set=my_conn.execute(text('''SELECT * from student LIMIT 0,10'''))
i=0 # row value inside the loop
for student in r_set:
for j in range(len(student)):
e = Entry(my_w, width=10, fg='blue')
e.grid(row=i, column=j)
e.insert(END, student[j])
i=i+1
my_w.mainloop()
from sqlalchemy import create_engine,text
from sqlalchemy.exc import SQLAlchemyError
my_path="D:\\testing\\sqlite\\my_db.db" #Change the path
my_conn = create_engine("sqlite:///" + my_path)
my_conn = my_conn.connect() # connection object
import tkinter as tk
from tkinter import *
my_w = tk.Tk()
my_w.geometry("400x250")
r_set=my_conn.execute(text('SELECT * from student LIMIT 0,10'))
i=0 # row value inside the loop
for student in r_set:
for j in range(len(student)):
e = tk.Label(my_w, width=10, fg='blue',text=student[j],anchor='w')
e.grid(row=i, column=j,padx=2)
i=i+1
my_w.mainloop()
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.
16-03-2021 | |
| Can you change the location of the table in the window | |
23-03-2021 | |
| yes by adding starting value to i ( now it starts from 0 ) any other value , i =2. But fill with some value of row=1. Similarly you can change the value of j to 2 or 3 and fill the value of column 0 and column 1. | |
16-04-2021 | |
| I don't know if im doing something wrong but this does not work for me. | |
17-04-2021 | |
| What is the error you are getting ? Break this to different steps , first display the data and then add Tkinter and check where the problem is | |
20-04-2021 | |
| I have no errors, just when I change the value of J and I it does not alter the position of the table. | |