Just committed a patch to the trunk that allows using prepared
statements, as suggested by Justin.
The following methods are added to the classic module:
prepare(), query_prepared(), describe_prepared(), delete_prepared()
The methods use the underlying functions in libpq for dealing with
prepared statements. The last two methods are not really important, they
are only added for completeness sake.
Here is an example for how to use this:
###
db.prepare('select-tweets', "SELECT * FROM tweets")
db.prepare('insert-tweet', "INSERT INTO tweets VALUES($1, $2, $3)")
db.truncate('tweets')
db.query_prepared('insert-tweet', [1, 'trump', 'so sad'])
db.query_prepared('insert-tweet', [2, 'trump', 'cofefe'])
for row in db.query_prepared('select-tweets').getresult():
print("tweet {0}: {1} said: {2}".format(*row))
###
Let me know what you think.
I will also add documentation, but want to wait for feedback first.
Maybe we want to change or add something.
-- Christoph
_______________________________________________
PyGreSQL mailing list
[email protected]
https://mail.vex.net/mailman/listinfo/pygresql