By the way you can combine multiple insert statements in a single transaction to improve performace
as described here.
import sqlite3 def createDB(): db = sqlite3.connect('people.db') db.execute('create table boys(name, age)') db.commit() db.close() pass def writeDB(): db = sqlite3.connect('people.db') db.execute('insert into boys(name, age) values ("danushka",30)') db.commit() db.close() pass def readDB(): db = sqlite3.connect('people.db') L = db.execute('select name, age from boys').fetchall() print L db.close() pass if __name__ == "__main__": #createDB() #writeDB() readDB()
No comments:
Post a Comment