I did a search on fetchall() and found a great example at:
http://stackoverflow.com/questions/2440147/how-to-check-the-existence-of-a-row-in-sqlite-with-python
Best regards
Andre
On Saturday, January 26, 2013 5:33:47 PM UTC+2, Razvan Musaloiu-E. wrote:
Some nice examples are in the "MySQLdb module" section from:http://zetcode.com/db/mysqlpython/ The .fetchall()/.fetchone() will returns an empty tuple if the query doesn't return any rows:Sample code:con = rdbms.connect(instance=...)cur = con.cursor()cur.execute("CREATE TABLE IF NOT EXISTS test.t(i int)")cur.execute("SELECT * FROM test.t")print cur.fetchall()cur.execute("SELECT * FROM test.t")print cur.fetchall()Output:()()-- Razvan MEOn Sat, Jan 26, 2013 at 6:59 AM, Andre Bruton <andre...@gmail.com> wrote:
HiGoogle gives an example of how to add and list data from a Cloud SQL database, and that is running great.How would I search for a record using Python? I want to search for a record and do something if there is a record and do something else if there is no record.Does anyone have a working example that I can look at?Best regardsAndre F Bruton--
No comments:
Post a Comment