Skip to content

Instantly share code, notes, and snippets.

@dangayle
Created February 24, 2012 19:33
Show Gist options
  • Save dangayle/1903175 to your computer and use it in GitHub Desktop.
Save dangayle/1903175 to your computer and use it in GitHub Desktop.
Python Bottle SQLite Version
from bottle import route, run, install
from bottle_sqlite import SQLitePlugin
install(SQLitePlugin(dbfile='bottle.db'))
@route('/db/')
def database(db):
data = db.execute('SELECT SQLITE_VERSION()').fetchone()
print "SQLite version: %s" % data
run(host='localhost', port=8080)
@dangayle
Copy link
Author

This works:

from bottle import route, run, redirect,install, template
import sqlite3 as lite
import sys

@route('/db/')
def database():
    con = lite.connect('test.db')

    with con:

        cur = con.cursor()    
        cur.execute('SELECT SQLITE_VERSION()')

        data = cur.fetchone()

        return "SQLite version: %s" % data              

run(host='localhost', port=8080)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment