Zdravím. Hraju si s nástrojem Dejavu (http://projects.amor.org/
dejavu), snažím se udělat insert do databáze, ale nedaří se ..
koukněte na kousek kódu:

import dejavu
from dejavu import Unit,UnitProperty

arena = dejavu.Arena()
arena.logflags = dejavu.logflags.SQL + dejavu.logflags.IO

conf = {'Database': "database.db"}
arena.add_store("main", "sqlite", conf)
arena.register_all(globals())

sandbox = arena.new_sandbox()

class Test(Unit):
        title = UnitProperty(unicode)
        text = UnitProperty(unicode)

def create_tables():
        arena.create_storage(Test)

def insert_data():
        test = Test(title="Pokus 1", text="Text pokusu 1")
        test2 = Test(title="Pokus 2", text="Text pokusu 2")
        test3 = Test(title="Pokus 3", text="Text pokusu 3")

        sandbox.memorize(test)
        sandbox.memorize(test2)
        sandbox.memorize(test3)

        if sandbox.flush_all():
                print 'ok'
        else:
                print 'ups, failed'

if __name__ == '__main__':
        create_tables()
        insert_data()

flush_all() se nepovede, práva pro zápis do databáze jsou přidělena ..

_______________________________________________
Python mailing list
[email protected]
http://www.py.cz/mailman/listinfo/python

Odpovedet emailem