I'm trying to find if a row with a given primary key exists.
Is this the "right" way to do it?
I'm using Python 3.4 and Sqlite 3.8.2
from sqlalchemy.ext.automap import automap_base
from sqlalchemy import create_engine, exists
from sqlalchemy.schema import Table
from sqlalchemy.schema import MetaData
from sqlalchemy.sql import select
Base = automap_base()
engine = create_engine("sqlite:////archives.db")
conn = engine.connect()
# reflect the tables
Base.prepare(engine, reflect=True)
meta = MetaData()
messages = Table('messages', meta, autoload=True, autoload_with=engine)
s =
select([messages.c.message_id_hash]).where(messages.c.message_id_hash=='GQWMEJ3DJYPFDH2NJEDOIDZ3W2YBUFYP')
result = conn.execute(s)
print(result.first())
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.