1import sqlite3 as lite
2import sys
3
4try:
5 con = lite.connect('products.db')
6 cur = con.cursor()
7 cur.execute("CREATE TABLE drinks(Id INTEGER PRIMARY KEY AUTOINCREMENT, Name TEXT, Price REAL)")
8 cur.execute("CREATE TABLE fruits(Id INTEGER PRIMARY KEY AUTOINCREMENT, Name TEXT, Price REAL)")
9 con.commit()
10
11except e:
12 if con:
13 con.rollback()
14
15 print("Unexpected error %s:" % e.args[0])
16 sys.exit(1)
17finally:
18 if con:
19 con.close()
1#!/usr/bin/python
2
3import sqlite3
4
5conn = sqlite3.connect('test.db')
6
7print "Opened database successfully";
1from sqlalchemy import create_engineengine = create_engine('sqlite:///:memory:')dff.to_sql('mySQLtable', con = engine)sqldf = pd.read_sql('mySQLtable', con = engine)sqldf