×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    21

    database in pyS60

    Hi Experts,

    i am trying to do database operation. i used the link http://wiki.forum.nokia.com/index.php/Database_in_PyS60.

    Its working properly.

    Code:
        db = e32dbm.open(file_nam,"c") #open the file
        db[u"name"] = u" Gargi Das "
        db[u"place"] = u"Bhavnagar"
        db[u"Country"] = u"india"
        db.close()
    Now i want to insert multiple entries to database. (name of many people with address)

    How can it be done???

    Thanks in advance

    Regards,
    Rabeeh

  2. #2
    Regular Contributor
    Join Date
    Jan 2009
    Location
    India
    Posts
    138

    Thumbs up Re: database in pyS60

    Hi,

    Use add method and open database in 'cf' mode.

    Code:
    def read():  #define a read function to read a database
    	db = e32dbm.open(file_nam,"r") #open a file
    	for key, value in db.items():  #read it using the dictionary concept. 
    		print "KEY", key, "VALUES", value
    	db.close()
    
    def add(NAME, PLACE, COUNTRY):
    	db = e32dbm.open(file_nam,"cf") #open the file
    	db[u"name"] = unicode(NAME)
    	db[u"place"] = unicode(PLACE)
    	db[u"Country"] = unicode(COUNTRY)
    	db.close()
    
    
    print "adding into database...................."
    
    add("Pavan","Rajasthan","India")
    add("Rabeehkm","Your Place","Your Country")
    
    print "reading database......................."
    read()

    hope this may be help.
    Pavan Pareta
    Sr. Software Engineer
    http://windows-mobile-dev.blogspot.com

  3. #3
    Registered User
    Join Date
    Jun 2008
    Posts
    21

    Re: database in pyS60

    Quote Originally Posted by pavan.pareta View Post
    Hi,

    Use add method and open database in 'cf' mode.

    Code:
    def read():  #define a read function to read a database
    	db = e32dbm.open(file_nam,"r") #open a file
    	for key, value in db.items():  #read it using the dictionary concept. 
    		print "KEY", key, "VALUES", value
    	db.close()
    
    def add(NAME, PLACE, COUNTRY):
    	db = e32dbm.open(file_nam,"cf") #open the file
    	db[u"name"] = unicode(NAME)
    	db[u"place"] = unicode(PLACE)
    	db[u"Country"] = unicode(COUNTRY)
    	db.close()
    
    
    print "adding into database...................."
    
    add("Pavan","Rajasthan","India")
    add("Rabeehkm","Your Place","Your Country")
    
    print "reading database......................."
    read()

    hope this may be help.
    Hi pavan pareta,

    Thanks for the reply. i tried your code. but the result is as shown

    KEY Country VALUES Your Country
    KEY Place VALUES Your Place
    KEY Name VALUES Rabeehkm
    It is only showing the last entered data.. how can i get all data in the db?

    Thanks in Advance,
    Rabeeh

Similar Threads

  1. Database in pys60
    By v divya in forum Symbian
    Replies: 6
    Last Post: 2009-03-07, 23:59
  2. New to Python for S60 (PyS60)? Read this first!
    By croozeus in forum Nokia N9
    Replies: 2
    Last Post: 2008-10-17, 19:23
  3. PyS60 Talks #2 : PyS60 Extensions
    By croozeus in forum Symbian
    Replies: 14
    Last Post: 2008-09-15, 14:23
  4. database trouble
    By liafail in forum Symbian
    Replies: 6
    Last Post: 2005-12-28, 05:56
  5. database problem
    By sridhar_ratna in forum Symbian
    Replies: 1
    Last Post: 2003-04-18, 09:07

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×