Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 20:12, 14 October 2007.

How to use SQL

From Forum Nokia Wiki

DBMS is the native format for database on Symbian platform. Python for S60 provides a 'e32db' module to access dbms.

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).
Related Discussions
Thread Thread Starter Forum Replies Last Post
about DataBase ram4soft General Symbian C++ 2 2007-07-22 17:40
WAP / ASP boston786 General Browsing 0 2003-02-20 05:25
In Which Datatype stored Binary Data. Tanya Symbian User Interface 3 2007-05-28 05:33
关于数据库设计的疑问? jintian2005 Symbian 2 2007-04-28 13:58
WML / ASP boston786 Browsing and Mark-ups 0 2003-02-20 05:25
 
Powered by MediaWiki