From 9b46de6e6793adbf39c660700e37f3cc5ff8ddf5 Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Mon, 27 Jul 2020 10:29:33 +0000 Subject: [PATCH] [TD-1000] modify the python demo --- tests/examples/python/read_example.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/examples/python/read_example.py b/tests/examples/python/read_example.py index 73c4b95214..dd1475ec14 100644 --- a/tests/examples/python/read_example.py +++ b/tests/examples/python/read_example.py @@ -26,7 +26,6 @@ if __name__ == '__main__': # Generate a cursor object to run SQL commands c1 = conn.cursor() - # Create a database named db try: c1.execute('create database if not exists db ') @@ -50,9 +49,11 @@ if __name__ == '__main__': raise(err) # insert data - for i in range(10000): + for i in range(10): try: - c1.execute("insert into t values ('%s', %d, %f, '%s')" % (start_time, random.randint(1,10), random.randint(1,10)/10.0, 'hello')) + value = c1.execute("insert into t values ('%s', %d, %f, '%s')" % (start_time, random.randint(1,10), random.randint(1,10)/10.0, 'hello')) + #if insert, value is the affected rows + print(value) except Exception as err: conn.close() raise(err) @@ -70,6 +71,11 @@ if __name__ == '__main__': # Use fetchall to fetch data in a list data = c1.fetchall() + for col in data: + print(col) + + print('Another query method ') + try: c1.execute('select * from db.t') except Exception as err: -- GitLab