DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
SQL In Python Series 60
DBMS is the native format for database on symbian platform.
Python for series 60 provide a 'e32db' module to access dbms.
import e32db
db = e32db.Dbms()
dbv = e32db.Db_view()
db.open(u'C:\\System\\Data\\Contacts.cdb ') # open database file
# search and retrieve from a row
def select_row(query):
dbv.prepare(db, unicode(query))
dbv.first_line()
dbv.get_line()
result = []
for i in range(dbv.col_count()):
result.append(dbv.col(i+1))
return result
# search and retrieve from a column
def select_col(query):
dbv.prepare(db, unicode(query))
dbv.first_line()
result = []
for i in range(dbv.count_line()):
dbv.get_line()
result.append(dbv.col(1))
dbv.next_line()
return result
# now it's quite easy to query anything, for example
# get the id of my friend "Jakapong"
id, = select_row("select parent_cmid from identitytable where cm_firstname='Jakapong' ")
I show more example here at nokia forum.
http://discussion.forum.nokia.com/forum/showthread.php?threadid=55674





