From 8e2c8d669aa547cf8749fa774160f4d05fff121a Mon Sep 17 00:00:00 2001 From: leonoverweel Date: Mon, 27 Feb 2017 02:14:04 +0100 Subject: Add Python script to view a table in the db --- database/view-table.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 database/view-table.py (limited to 'database') diff --git a/database/view-table.py b/database/view-table.py new file mode 100644 index 00000000..615b4081 --- /dev/null +++ b/database/view-table.py @@ -0,0 +1,17 @@ +import os +import sqlite3 +import sys + +try: + BASE_DIR = directory_name=sys.argv[1] +except: + BASE_DIR = os.path.dirname(os.path.abspath(__file__)) +db_location = os.path.join(BASE_DIR, 'opendc.db') + +conn = sqlite3.connect(db_location) +c = conn.cursor() + +rows = c.execute('SELECT * FROM ' + sys.argv[2]) + +for row in rows: + print row -- cgit v1.2.3