Added two test databases for user to try the merge before tampering with their files.

pull/2/head
Charlie Duso 8 years ago
parent 3535dc1b02
commit f1ec8ded5d

@ -10,11 +10,13 @@
################################################################################ ################################################################################
import sqlite3 import sqlite3
import time
import datetime
############################ Global Variables ################################## ############################ Global Variables ##################################
################################################################################ ################################################################################
dbCount = 1 # Variable to count the number of databases dbCount = 0 # Variable to count the number of databases
############################ Function Definitions ############################## ############################ Function Definitions ##############################
################################################################################ ################################################################################
@ -49,7 +51,7 @@ def getTableNames():
# Gets the column names of a table # Gets the column names of a table
# #
# @param dbName the name of the database file (i.e. "example.db") # @param dbName the name of the database file (i.e. "example.db")
# @return a string array of the column names - strips primary ids # @return a string array of the column names - strips primary ids
def getColumnNames( tableName ): def getColumnNames( tableName ):
curs.execute("PRAGMA table_info(%s);" % str(tableName)) curs.execute("PRAGMA table_info(%s);" % str(tableName))
temp = curs.fetchall() temp = curs.fetchall()
@ -66,7 +68,7 @@ def getColumnNames( tableName ):
# #
# @param list1 the first list parameter for comparison # @param list1 the first list parameter for comparison
# @param list2 the second list parameter for comparison # @param list2 the second list parameter for comparison
# @return will return a boolean (0 lists !=, 1 lists ==) # @return will return a boolean (0 lists !=, 1 lists ==)
def compareLists(list1, list2): def compareLists(list1, list2):
if len(list1) != len(list2): if len(list1) != len(list2):
return 0 return 0
@ -87,9 +89,9 @@ def mergeTable(tableName, columnNames, dbNameTableName):
curs.execute("INSERT INTO %s (%s) SELECT %s FROM %s;" % curs.execute("INSERT INTO %s (%s) SELECT %s FROM %s;" %
(tableName, columnNames, columnNames, dbNameTableName)) (tableName, columnNames, columnNames, dbNameTableName))
conn.commit() conn.commit()
############################## Merge Script ####################################
############################## Input Parameters ################################
################################################################################ ################################################################################
# Create the initial database connection - everything will be merged to here # Create the initial database connection - everything will be merged to here
@ -97,8 +99,16 @@ conn = sqlite3.connect('') # Enter the name of the database
curs = conn.cursor() # Creates a cursor for use on the database curs = conn.cursor() # Creates a cursor for use on the database
# Attach databases # Attach databases
attachDatabase('') # Enter the name of the database (i.e. "example.db") attachDatabase('') # Enter the name of the database (i.e. "example.db")
attachDatabase('') attachDatabase('')
attachDatabase('') attachDatabase('')
attachDatabase('') attachDatabase('')
############################## Merge Script ####################################
################################################################################
# Compare databases
# Merge databases
print("Merging databases. Started at: " + time.time())
print("Databases finished merging. Time elapsed: ")

Loading…
Cancel
Save