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\n\n"
while True:
    cmd = input("sql> ")#in python2.7 use raw_input
        if cmd.lstrip().upper().startswith("SELECT"):
            print cur.fetchall()
    except sqlite3.Error, e:
       print "An error occurred:", e.args[0]
Community content is available under CC-BY-SA unless otherwise noted.