Tornado – SQLite

I received a couple of requests for Tornado’s interaction with SQLite interface. So, here’s the blog…

SQLite is a file based and transactional database engine. Because of it’s lightweight capabilities, SQLite’s adoption has increased in the recent past. You can know more about it here. Below is an example of Tornado’s interaction with SQLite DB.

Consider a SQLite DB having table ‘stud’ with schema as below:

stud    table    CREATE TABLE stud (id INTEGER PRIMARY KEY, marks NUMERIC, name TEXT)
id    field    INTEGER PRIMARY KEY
name    field    NUMERIC
marks    field    TEXT

In Tornado, we implement two pages:

Code snippets implementing this in Tornado can be viewed below:

Step 1: When user logs in to http://localhost:8888/create, he adds name and marks for a student. [Student id is auto generated]

Step 2: When user clicks on ‘Add’, a record gets added successfully

Step 3: Clicking on ‘Show Records’ shows all the records user has added to ‘stud’ table.

3 thoughts on “Tornado – SQLite

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s