I prepared a short python script which will write a csv file from multiple sqlite databases.
#function for merging sqlite files to csv
def convert_sqlite_to_csv(inputFolder, ext, tableName):
""" inputFolder - Folder where sqlite files are located.
ext - Extension of your sqlite file (eg. db, sqlite, sqlite3 etc.)
tableName - table name from which you want to select the data.
"""
csvWriter = csv.writer(open(inputFolder+'/output.csv', 'w', newline=''))
for file1 in os.listdir(inputFolder):
if file1.endswith('.'+ext):
conn = sqlite3.connect(inputFolder+'/'+file1)
cursor = conn.cursor()
cursor.execute("SELECT * FROM "+tableName)
rows = cursor.fetchall()
for row in rows:
csvWriter.writerow(row)
continue
else:
continue
Or find the script on github link below for converting multiple files in a folder.
python multiple_sqlite_files_tocsv.py -d <inputFolder> -e <extension> -t <tableName>
will output the data to output.csv file.
Jupyter notebook and a python script are on github.
https://github.com/darshanz/CombineMultipleSqliteToCsv