FANDOM


This is a very simple SQLite shell. It creates a database in memory.

This is a example of using the DB-API.

import sqlite3
 
db = sqlite3.connect(':memory:')
cur = db.cursor()
 
print "SQLite 3 simple shell from python.wikia.com\n\n"
 
while True:
    cmd = input("sql> ")#in python2.7 use raw_input
    try:
        cur.execute(cmd.strip())
        if cmd.lstrip().upper().startswith("SELECT"):
            print cur.fetchall()
    except sqlite3.Error, e:
       print "An error occurred:", e.args[0]