Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Archived:Database in PySymbian

From Wiki
Jump to: navigation, search

Archived.pngAquivado: 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
Created: gaba88 (15 Jul 2008)
Last edited: hamishwillee (31 May 2013)



The Symbian OS in Nokia S60 smart phones include a relational database engine and PySymbian provides two good interfaces to that. Both the interfaces can be found by the following two modules.

  1. e32db Module
  2. e32dbm Module

Note also that there is an experimental port of PySymbian port of MySQL-Python available.

e32db Module

This interface in PySymbian provides a low level access to database. Its supports transaction and querying with the use of Simple Query Language . This Module can be very useful for applications that needs to store relationally organized data and want to perform queries frequently. In the e32db case the database is local more than a real thats why this module is not frequently used.

e32dbm module

In most cases the e32dbm module is used the reason for this is e32dbm module is very simple and it supports a lots of dictionary functions like adding, deleting the key-value pairs. The code snippet will make it more clear about this module. e32dbm module actually is a mixture of file and a dictionary. It is simply opened as file and operated as a dictionary.

import e32dbm  #import the module
file_nam = u"e:\\python\\wiki.db" #assign the name of the file to a variable
def write(): #define the write function to write in a database
db =,"c") #open the file
db[u"name"] = u" Gargi Das "
db[u"place"] = u"Bhavnagar"
db[u"Country"] = u"india"
def read(): #define a read function to read a database
db =,"r") #open a file
for key, value in db.items(): #read it using the dictionary concept.
print "KEY", key, "VALUES", value
print "writing database......................."
print "reading database......................."

the code above seems to be very self explanatory and one thing to mention is the modes in which we can access different database files.

Modes of accessing a database file

The following are the modes in which one can open a database file.

  • r - opens a database file for reading only.
  • w - opens a database file for reading and writing.
  • c - opens a database file for reading and writing. It creates a new database file if the file doesn't exist.
  • n - opens a database for reading and writing. It creates and empty database if the database doesn't exist or clears the previous one.
This page was last modified on 31 May 2013, at 01:07.
87 page views in the last 30 days.