My favorites | Sign in
Project Home Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Project Information
Members
Links

Database system written in python for small applications that want to store small ammounts of data (0-30k rows). Parsing file, searching and changing couple rows in table with 30k rows takes around 0.3 second.

Features:

  • Small query language based on python conditions.
  • Dependancy free.
  • Object oriented.

Current version: 0.1

Copyright (c) 2006, IF Research Polska (http://www.ifresearch.pl)

Examples of usage:

    
    from ocfdb import ocfdb, OCFDBError
        
    # packages file format:
    # MODIFYDATE:123456789:
    # TABLE:packages:
    # id;name;version
    # 1;clamav;2.0
    # 2;dspam;3.6.4
    
    # file is packed with gzip
    # $: gzip packages
    # /\ this will output packages.gz
    
    # database initialization
    try:
        db = ocfdb('packages.gz')
    except OCFDBError:
        print "Database Error", OCFDBError
    # getting rows, this will return rows internal IDs in list, not column values nor objects    
    rowids = db.packages.getrows('int(__row.id) <= 2') # we have to remember that all columns values are strings
 
    # to get objects we have to fetch them from database:    
    rows = db.packages.getrowsbyId(rowids)
    
    #now when we have rows we can do something on them:
    
    for row in rows:
        print row.name, row.version
        
    # let's now update name column in first row    
    
    rows[0].name = "clamav"

    print rows[0].name
    # returns: clamav
    
    # so when we do any changes, we have to save database, so they won't be lost at another opening of database
    
    db.savedatabase()
Powered by Google Project Hosting