Commit d8cb1308 authored by LammLukas's avatar LammLukas

Added db functions to utils

parent 9b8e33b4
......@@ -4,6 +4,7 @@ Package providing various utilities for the Miraculix software
Author: L. Lamm (lamm@ifam.rwth-aachen.de)
"""
import csv
import sqlite3
def write_csv(file, data):
......@@ -26,4 +27,13 @@ def get_index_csv_data(data, entry_dict):
indices = {}
for entry_key in entry_dict:
indices[str(entry_key)] = data[0].index(entry_dict[entry_key])
return indices
\ No newline at end of file
return indices
def db_table_exists(db_cursor, tbl_name):
"""Check if table exists in given sqlite database"""
db_cursor.execute(" SELECT count(name) FROM sqlite_master WHERE type='table' AND name=?", [tbl_name])
if not db_cursor.fetchone()[0] == 1:
return False
else:
return True
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment