ok. so i figured out how to create database and run queries using the phone db.
There are 3 files.
db.py -- class object for querying db.
db_schema.py - file that needs to be run once for creating the db. The db has to be stored in root directory (E:/Python)
db_testing.py - examples on how to run queries
This is a db_testing.py:
# Change __exec_path to the path of your python script dir
__exec_path = "E:\\Python\\"
dbname = "loCal_db"
import sys
sys.path.append(__exec_path)
from db import db
# Opens E:\\Python\loCal_db.db
mydb = db(__exec_path+dbname+'.db')
########insert statement
mydb.query("insert into location_list values (15,1,'note here','w',0)")
######different select statement
row = mydb.select_row('SELECT * FROM location_list')
print "select one row",str(row)
rows= mydb.select_all('SELECT * FROM location_list')
print "all rows:"
for r in rows:
print str(r)
print ""
print ""
rows = mydb.select_all('select * from location_list where uid=2')
print "all rows for second user"
for r in rows:
print str(r)
print ""
print ""
rows = mydb.select_col('select name from location_list')
print "all names"
for r in rows:
print str(r)
print ""
print ""
