Hi,
The following session is never saved to the db, not even a schema is
created, but a query returns correctly. I assume that there is local
caching going on. but session.dirty etc doesn't show anything. So, two
questions:
First, how (if possible) can I force sqla to hit the db? In this case, how
can I force it to return an error for the line
print session.execute(q1).fetchall()
?
Second, how can I get sqla to show there is data unsaved to the db? I
tried dirty and new. Thanks in advance.
Regards, Faheem
************************************************************************
dbuser =
password =
dbname =
dbstring = "postgres://%s:%...@localhost:5432/%s"%(dbuser,password, dbname)
from sqlalchemy import create_engine
from sqlalchemy.orm sessionmaker
db = create_engine(dbstring)
from sqlalchemy import MetaData
from sqlalchemy.sql import text
meta = MetaData()
meta.bind = db
meta.create_all()
Session = sessionmaker()
session = Session(bind=db)
session.execute("DROP SCHEMA IF EXISTS foo CASCADE; CREATE SCHEMA foo;")
q = text("DROP TABLE IF EXISTS foo.activity; CREATE TABLE foo.activity AS
SELECT * FROM pg_stat_activity;")
session.execute(q)
q1 = text("select * from foo.activity;")
print session.execute(q1).fetchall()
print session.dirty
print session.new
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.