×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Regular Contributor
    Join Date
    Mar 2007
    Posts
    153

    Data Base is growing when UPDATEing a data set ??

    Hello,
    why is my Symbian Database growing when I just UPDATE a data set?
    There is just one data set in the following example which I just UPDATE several times. But the DB is growing after each UPDATE operation. The database is growing into infinity (kB->MB->GB) but just contains one data set

    Code:
    ##database test##
    import e32, e32db
    db_name = u"E:\\test\\test_db.db"
    
    
    ## check if the db is existing already, if not create the db and insert a single data set
    try:
        db = e32db.Dbms()
        db.open(db_name)
    except:
        db.create(db_name)
        db.open(db_name)
        sql_create = u"CREATE TABLE table1 (col1 VARCHAR, col2 VARCHAR)"
        db.execute(sql_create)
    
        ## write just one data set
        index = 1
        value = 0
        sql_add = u"INSERT INTO table1 (col1, col2) VALUES ('%s', '%s')" % (index, value)
        db.execute(sql_add)
    
    
    ## update the data set again and again
    i = 0
    while i <= 10:
        value += 1
        i += 1
        sql_add = u"UPDATE table1 SET col2 = '%s' WHERE col1 = '%s'"%(value,index)
        db.execute(sql_add)
        e32.ao_sleep(1)
    print "Update Ready"
    What am I doing wrong??

    Thx for help
    novid

  2. #2
    Regular Contributor
    Join Date
    Dec 2007
    Location
    Tempe, AZ
    Posts
    411

    Re: Data Base is growing when UPDATEing a data set ??

    Hi novis,
    I think your code is giving wrong/unexpected output because you have initialised the index and value variables in except block, and i think when you are running this script you already have formed database so interpreter never enters the except block.
    So value of index and value are never initialised, thats why unexpected output.
    please rectify me if i gave you wrong answer.
    Last edited by shubhendra; 2008-05-29 at 10:25.
    IDEAS is all they need but still they think only Genius can give them that.

  3. #3
    Regular Contributor
    Join Date
    Mar 2007
    Posts
    153

    Re: Data Base is growing when UPDATEing a data set ??

    Thx shubhendra,
    i changed it,
    but the result keeps the same. instead of keeping nearly the same size, the DB is growing on every UPDATE.
    I think there must be something wrong in my concept. But I can't find it
    Code:
    ##database test##
    import e32, e32db
    db_name = u"E:\\test\\test_db.db"
    index = 1
    value = 0
    
    ## check if the db is existing already
    try:
        db = e32db.Dbms()
        db.open(db_name)
    except:
        db.create(db_name)
        db.open(db_name)
        sql_create = u"CREATE TABLE table1 (col1 VARCHAR, col2 VARCHAR)"
        db.execute(sql_create)
    
        ## write just one data set
        sql_add = u"INSERT INTO table1 (col1, col2) VALUES ('%s', '%s')" % (index, value)
        db.execute(sql_add)
    
    
    ## update the data set again and again
    i = 0
    while i <= 10:
        value += 1
        i += 1
        sql_add = u"UPDATE table1 SET col2 = '%s' WHERE col1 = '%s'"%(value,index)
        db.execute(sql_add)
        e32.ao_sleep(1)
    print "Update Ready"
    Can someone give a hint pls?

  4. #4
    Regular Contributor
    Join Date
    Dec 2007
    Location
    Tempe, AZ
    Posts
    411

    Re: Data Base is growing when UPDATEing a data set ??

    Novis,
    As far as i understand your code there seems to be no problem with concept, you are storing value of "value" in "col2" if col1=index value i.e. if col1=1 then only execute the update query.

    Please check if the database contains the value of col1 as 1 intially if datbase already present. Thats what seems to be place where any problem can exist.
    IDEAS is all they need but still they think only Genius can give them that.

  5. #5
    Regular Contributor
    Join Date
    Mar 2007
    Posts
    153

    Re: Data Base is growing when UPDATEing a data set ??

    Hi shubhendra,
    if i read out all values from the table in the end, then there is just and only one row col1:col2 = 1:11

    so that does not seem to be the problem
    I don't think that it is correct, that a table grows by UPDATEing this single value.
    I've no explenation for that...
    Last edited by novis; 2008-05-29 at 12:26.

  6. #6
    Regular Contributor
    Join Date
    Dec 2007
    Location
    Tempe, AZ
    Posts
    411

    Re: Data Base is growing when UPDATEing a data set ??

    Ok so maybe some different problem,

    but Output is col1:col2=1:10 really?

    Because "while i<=10:" makes 'i' and 'value' equal to 11 when loop is executed for the last time.

    I think i am doing right calculation.
    IDEAS is all they need but still they think only Genius can give them that.

  7. #7
    Super Contributor
    Join Date
    Mar 2003
    Location
    Espoo, Finland
    Posts
    976

    Re: Data Base is growing when UPDATEing a data set ??

    Quote Originally Posted by novis View Post
    I don't think that it is correct, that a table grows by UPDATEing this single value.
    I've no explenation for that...
    That's the normal Symbian database behaviour. You make any change, for example delete something from database, and database filesize grows. If you want the make the filesize smaller, you should try this:

    compact()
    Compacts the database, reclaiming unused space in the database file.
    Nothing to worry about,

    --jouni

  8. #8
    Regular Contributor
    Join Date
    Mar 2007
    Posts
    153

    Re: Data Base is growing when UPDATEing a data set ??

    @JOM,

    ur right mate.
    The following code wipes out all deleted data sets in the DB.
    Code:
    >>> import e32db
    >>> db_name = u"E:\\test\\test_db.db"
    >>> db = e32db.Dbms()
    >>> db.open(db_name)
    >>> db.compact() ##here we go
    My one data set DataBase was reduced in size from 1,45 MB to just 151 Byte

    Thx again 2 JOM (100% relevant statement, very clear, very helpful)

    novis

  9. #9
    Regular Contributor
    Join Date
    Dec 2007
    Location
    Tempe, AZ
    Posts
    411

    Re: Data Base is growing when UPDATEing a data set ??

    Thanks JOM really didn't had any idea of db.compact(), it really kept me wondering why size is increasing like anything.
    IDEAS is all they need but still they think only Genius can give them that.

Similar Threads

  1. Can not Access LifeBlog Data base in N95
    By aamitgupta in forum General Development Questions
    Replies: 8
    Last Post: 2008-04-02, 10:53
  2. Replies: 2
    Last Post: 2004-09-15, 22:47
  3. How to set text data to TBuf<16>?
    By cidhx in forum Symbian
    Replies: 2
    Last Post: 2003-12-03, 01:33
  4. how to fetch data from mobile phone set 5110
    By adubey in forum PC Suite API and PC Connectivity SDK
    Replies: 1
    Last Post: 2002-07-11, 09:14
  5. How to set a RLine in Voice, Data or Fax mode ?
    By Lebihen in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2002-07-01, 06:58

Posting Permissions

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