On Feb 10, 2010, at 5:24 PM, Tarek Ziadé wrote:
Hi,
I am using this pattern to execute a simple query on a database:
def execute(sqluri, query):
engine = create_engine(sqluri)
connection = engine.connect()
try:
connection.execute(query)
finally:
connection.close()
I was wondering if this was the best pattern, or if something simpler exists..
engine.execute(query) is certainly simpler.But don't create_engine() many
times in one application for the same URL, thats like configuring a log handler
everytime you need to log something.
Regards
Tarek
--
Tarek Ziadé | http://ziade.org
--
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.
--
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.