Namespaces
Variants
Actions

Archived:How to use SQL on DBMS database with PySymbian

Jump to: navigation, search
Archived.png
Aquivado: Este artigo foi arquivado, pois o conteúdo não é mais considerado relevante para se criar soluções comerciais atuais. Se você achar que este artigo ainda é importante, inclua o template {{ForArchiveReview|escreva a sua justificativa}}.

All PySymbian articles have been archived. PySymbian is no longer maintained by Nokia and is not guaranteed to work on more recent Symbian devices. It is not possible to submit apps to Nokia Store.
Article Metadata

Article
Created: cyke64 (15 Mar 2007)
Last edited: hamishwillee (31 May 2013)

This article shows how to access DBMS, the native Symbian database, from PySymbian. The module used is e32db.

import e32db
db = e32db.Dbms()
dbv = e32db.Db_view()
db.open(u'C:\\system\\data\\bookmarks1.db') # 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
 
def select_all(query):
dbv.prepare(db, unicode(query))
dbv.first_line()
rows = []
for i in range(dbv.count_line()):
dbv.get_line()
result = []
for i in range(dbv.col_count()):
try:
result.append(dbv.col(i+1))
except: # in case coltype 16
result.append(None)
rows.append(result)
dbv.next_line()
return rows

Now you can simply call

select_row('SELECT * FROM Favourites')  # 1 row
select_all('SELECT * FROM Favourites') # all rows
 
 
# For non-select SQL, you can simply use db.execute(query).
This page was last modified on 31 May 2013, at 04:05.
137 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved