I'm trying to create an api (sqlalchemy.simple?) that allows unsophisticated db manipulation without explicit table classes.  (Code attached.)  Seems to work fine except I can't get inserts to work.  My objects go into the UnitOfWork but they still do not get committed.  I suspect it's something simple to get them marked "dirty" for commit, but my code diving patience for the evening is exhausted.  Help? :)

Demo of the problem:

CREATE TABLE books (
    id                serial PRIMARY KEY,
    title            text NOT NULL,
    published_year    char(4) NOT NULL,
    authors            text NOT NULL
);

from sqlalchemy import create_engine
engine = create_engine('postgres', {'database': 'pyweboff', 'user': 'spyce', 'password': 'spyce'})
db = DbSoup(engine)
db.books(title='foo', published_year='1111', authors='asdf')
from sqlalchemy import objectstore
print objectstore.get_session().uow.new # there it is!
db.commit()
# but no new rows in books!

--
Jonathan Ellis
http://spyced.blogspot.com

Attachment: soup.py
Description: application/httpd-python

Reply via email to