Socialify

Folder ..

Viewing sql_functions.py
16 lines (12 loc) • 382.0 B

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
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