cyclone.sqlite — Inline SQLite

An inline SQLite helper class.

All queries run inline, temporarily blocking the execution. Please make sure you understand the limitations of using SQLite like this.


import cyclone.web
import cyclone.sqlite

class SQLiteMixin(object):
    sqlite = cyclone.sqlite.InlineSQLite("mydb.sqlite")

class MyRequestHandler(cyclone.web.RequestHandler):
    def get(self):
        rs = self.sqlite.runQuery("SELECT 1")

There is no Deferred responses, and no need to yield anything.

class cyclone.sqlite.InlineSQLite(dbname=':memory:', autoCommit=True)[source]

An inline SQLite instance

Create new SQLite instance.

runQuery(query, *args, **kwargs)[source]

Use this function to execute queries that return a result set, like SELECT.

Example (with variable substitution):

sqlite.runQuery("SELECT * FROM asd WHERE x=? and y=?", [x, y])
runOperation(command, *args, **kwargs)[source]

Use this function to execute queries that do NOT return a result set, like INSERT, UPDATE and DELETE.


sqlite.runOperation("CREATE TABLE asd (x int, y text)")
sqlite.runOperation("INSERT INTO asd VALUES (?, ?)", [x, y])
runOperationMany(command, *args, **kwargs)[source]

Same as runOperation, but for multiple rows.


sqlite.runOperationMany("INSERT INTO asd VALUES (?, ?)", [
                            [x1, y1], [x2, y2], [x3, y3]

Commits pending transactions


Gives up pending transactions


Destroys the instance

Previous topic

cyclone.bottle — Bottle application style

Next topic

Asynchronous networking

This Page