Some nice examples are in the "MySQLdb module" section from:
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 ME
On Sat, Jan 26, 2013 at 6:59 AM, Andre Bruton <andrebruton@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