Skip to Content
Tkinter GUI Programming by Example
book

Tkinter GUI Programming by Example

by David Love
April 2018
Beginner content levelBeginner
340 pages
7h 54m
English
Packt Publishing
Content preview from Tkinter GUI Programming by Example

Adding data to a SQLite database

In order to add data to our SQLite database, we need to use an insert statement. We provide the insert statement with the name of the table we are updating and the values we wish to add to this table. We can then execute this as a query in the same way as before.

The insert syntax is as follows:

INSERT INTO table (column1, column2) VALUES (value1, value2);

So, for our users table, we could use the following:

INSERT INTO users (username, real_name) VALUES ("davidlove", "David Love");

Since we are going to be doing this from various flask endpoints, we should establish a method of doing this easily. To achieve this, make a file in your server folder, called database.py and add the following code:

import sqlite3 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Tkinter GUI Application Development Blueprints, Second Edition - Second Edition

Tkinter GUI Application Development Blueprints, Second Edition - Second Edition

Bhaskar Chaudhary

Publisher Resources

ISBN: 9781788627481Supplemental Content