December 13th, 2012, 08:48 AM
How to display content of a sqlite database?
I'm writing a software in python and glade gui that stores data in a sqlite database. Ive managed to make the program insert data but I want to be able to display the content of the database in a list where the user can select different records. How do I do this?
December 13th, 2012, 11:08 AM
I'd use sqlite directly through a subprocess and parse the information myself. Python almost certainly has a library to simplify this.
$ sqlite3 ~/.config/chromium/Default/databases/Databases.db
Databases Quota meta
sqlite> .schema Databases
CREATE TABLE Databases (id INTEGER PRIMARY KEY AUTOINCREMENT, origin TEXT NOT NULL, name TEXT NOT NULL, description TEXT NOT NULL, estimated_size INTEGER NOT NULL);
CREATE INDEX origin_index ON Databases (origin);
CREATE UNIQUE INDEX unique_index ON Databases (origin, name);
sqlite> select * from Databases;
sqlite> .dump Databases
Last edited by b49P23TIvg; December 13th, 2012 at 11:10 AM.
[/code] are essential for python code and Makefiles!
December 14th, 2012, 03:54 AM
Put python sqlite3 into your favourite search engine and you'll get several good tutorials for using SQLite inside of python.
A very quick routine that prints out a SQL statement:
conn = sqlite3.connect("mydatabase.db")
cursor = conn.cursor()
sql = "SELECT * FROM sometable WHERE condition"
for row in cursor.execute(sql):