aboutsummaryrefslogtreecommitdiff
path: root/functions
diff options
context:
space:
mode:
Diffstat (limited to 'functions')
-rw-r--r--functions/array_functions.py3
-rw-r--r--functions/sql_functions.py16
2 files changed, 19 insertions, 0 deletions
diff --git a/functions/array_functions.py b/functions/array_functions.py
new file mode 100644
index 0000000..be15abd
--- /dev/null
+++ b/functions/array_functions.py
@@ -0,0 +1,3 @@
+def get_list_of_dict(keys, list_of_tuples):
+ list_of_dict = [dict(zip(keys, values)) for values in list_of_tuples]
+ return list_of_dict
diff --git a/functions/sql_functions.py b/functions/sql_functions.py
new file mode 100644
index 0000000..5cc2ae9
--- /dev/null
+++ b/functions/sql_functions.py
@@ -0,0 +1,16 @@
+import sqlite3 as sql
+import pandas as pd
+
+
+def execute_sql_statement(sql_statement):
+ conn = sql.connect("database.db")
+ cur = conn.cursor()
+ cur.execute(sql_statement)
+ rows = cur.fetchall()
+ return rows
+
+
+def run_sql_pandas(sql_statement):
+ conn = sql.connect("database.db")
+ df = pd.read_sql_query(sql_statement, conn).to_records(index=False)
+ return df