From 98c1ca40ac21017a8d146d33e0c947127bb59f49 Mon Sep 17 00:00:00 2001 From: Charlie Duso Date: Tue, 28 Jun 2016 21:56:20 -0700 Subject: [PATCH] More modifications towards how column names and table names are pulled from a database. -Column names and table names are now returned with a string list of each respective name --- mergeScript.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/mergeScript.py b/mergeScript.py index b1d9fab..92fb626 100644 --- a/mergeScript.py +++ b/mergeScript.py @@ -38,17 +38,25 @@ def closeConnection(): # # @param dbName the name of the database file (i.e. "example.db") # @return a string array of the table names -def getTableNames( dbName ): +def getTableNames(): curs.execute("SELECT name FROM sqlite_master WHERE type='table';") - tables = curs.fetchall() + temp = curs.fetchall() + tables = [] + for i in range(0, len(temp)): + tables.append(temp[i][0]) return tables # Gets the column names of a table # # @param dbName the name of the database file (i.e. "example.db") # @return a string array of the table names and their respective column names -def getColumnNames( dbName, table ): - curs.execute("PRAGMA table_info(%s);" % str(tables[0][0]) +def getColumnNames( tableName ): + curs.execute("PRAGMA table_info(%s);" % str(tableName)) + temp = curs.fetchall() + columns = [] + for i in range(0, len(temp)): + columns.append(temp[i][1]) + return columns ############################## Merge Script ####################################