Python Wiki

Simple SQLite shell

43pages on
this wiki
Add New Page
Talk0 Share

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:')
print "SQLite 3 simple shell from\n\n"
while True:
    cmd = input("sql> ")
        if cmd.lstrip().upper().startswith("SELECT"):
            print cur.fetchall()
    except sqlite3.Error, e:
       print "An error occurred:", e.args[0]

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.