aboutsummaryrefslogtreecommitdiff
path: root/sql_functions.py
diff options
context:
space:
mode:
authorPriyansh <[email protected]>2021-12-02 16:37:41 -0500
committerPriyansh <[email protected]>2021-12-02 16:37:41 -0500
commit74d6f019cc90214833c00ec45ed92ffc45c07dd7 (patch)
tree379ce1bbdc6e80c0edd0fd977edfd9a5ec7e0765 /sql_functions.py
parent2b016a3a7af086d42e5e569b0f4f0ceb72c67f26 (diff)
downloadtemp_pred_arima-74d6f019cc90214833c00ec45ed92ffc45c07dd7.tar.xz
temp_pred_arima-74d6f019cc90214833c00ec45ed92ffc45c07dd7.zip
Isolated SQL Functions, Passed JS Data to Flask, time series in a separate function
Diffstat (limited to 'sql_functions.py')
-rw-r--r--sql_functions.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/sql_functions.py b/sql_functions.py
new file mode 100644
index 0000000..313c449
--- /dev/null
+++ b/sql_functions.py
@@ -0,0 +1,18 @@
+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
+
+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 \ No newline at end of file