SQLite Dhananjay(123059008)

Introduction to Sqlite and its usage with python

1. Sqlite : SQLite is a software that implements a self-contained, serverless, zero- configuration, transactional SQL database engine. SQLite is the most widely deployedSQL database engine in the world. SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine.

To install : $ sudo apt-get install sqlite3 libsqlite3-dev

To create a data base, we only need to create a empty file : $ touch ex1.db

To connect to database through sqlite : $ sqlite3 ex1.db

There are various shells and command lines available for manipulating Sqlite databases.

2. SQLite Database browser It is a light GUI editor for SQLite databases. It can be used as a database management system.

3. Using python library sqlite for manipulating databases :

SQLite is a library that provides a lightweight disk-based database that doesn’t require a separate server process and allows accessing the database using a nonstandard variant of the SQL query language. Some applications can use SQLite for internal data storage. It’s also possible to prototype an application using SQLite and then port the code to a larger database such as PostgreSQL or Oracle.

SQLite Dhananjay(123059008)

import sqlite3 conn = sqlite3.connect('example.db') c = conn.cursor() c.execute('''CREATE stocks (date text, trans text, symbol text, qty real, price real)''') c.execute("INSERT INTO stocks VALUES ('2006-01- 05','BUY','RHAT',100,35.14)") conn.commit() conn.close()

Above script is a simple demo of ‘how to connect to a Sqlute db using puthon’. Using the library almost all database manipulations can be performed.

4. References

Referred during week 03 August 2013 Sqlite3 Resources: http://www.sqlite.org/ Sqlite browser: http://sourceforge.net/projects/sqlitebrowser/ Python Resources: http://docs.python.org/2/library/sqlite3.html