1. NodeBox 1
    1. Homepage
    2. NodeBox 3Node-based app for generative design and data visualization
    3. NodeBox OpenGLHardware-accelerated cross-platform graphics library
    4. NodeBox 1Generate 2D visuals using Python code (Mac OS X only)
  2. Gallery
  3. Documentation
  4. Forum
  5. Blog

bug in the database library

Posted by Giorgio O. on Dec 17, 2007

hello,

I just started using the database library (that's very cool), and it seems that the 'edit' method is not working properly.
If you run the "database_test.py" script that comes with the library, the instruction "book.pages.edit(3, pagenumber=1)" has no effect.

try:
    db = ximport("database")
except:
    db = ximport("__init__")
    reload(db)
 
book = db.create("book")
book.create_table("pages", ["title", "description", "pagenumber"])
 
book.pages.append(title="introduction", pagenumber=1)
book.pages.append(title="chapter one", pagenumber=2)
book.pages.append({"title": "chapter two", "pagenumber": 3})
 
print "Tables created", book.tables()
print "All pages:", book.pages.all()
 
print "Page 1:", book.pages.pagenumber("1")
print "Chapter two:", book.pages.find("*two", key="title")
 
book.pages.remove(1)
book.table("pages").remove(2)
print "Remaining pages:", book.sql("select * from pages")
 
book.pages.edit(3, pagenumber=1)
# in the debug output the pagenumber is still '3'
 
book.xml()
xml = open("book.xml").read()
print xml
 
book.close()


 
Posted by Giorgio O. on Dec 17, 2007

a quick fix is possible using the sql syntax...

book.sql("UPDATE pages SET pagenumber = 'xxx' WHERE id='3'")



Posted by Tom De Smedt on Dec 17, 2007

It should be fixed in the new release I've put online.
-- tom