64 lines
1.6 KiB
Python
64 lines
1.6 KiB
Python
import mysql.connector
|
|
import os
|
|
import db_cred as db_credentials
|
|
|
|
import pandas as pd
|
|
from sqlalchemy import create_engine
|
|
|
|
class db_module():
|
|
def __init__(self):
|
|
super().__init__()
|
|
self.currentWorkingDB: str
|
|
self.engine = None
|
|
|
|
def setup_engine(self):
|
|
self.engine = create_engine(db_credentials.engine_url)
|
|
print("Engine Created")
|
|
|
|
def create_table(self, tableName:str = ""):
|
|
pass
|
|
|
|
def does_table_exist(self, tableName:str = ""):
|
|
pass
|
|
|
|
def delete_table(self, tableName:str = ""):
|
|
pass
|
|
|
|
#This was a old function used prior to the creation of this class. I need to remake it.
|
|
def get_data_old(self, tableName:str = "", key:str = ""):
|
|
table = '_channel_commands'
|
|
table = tableName
|
|
|
|
|
|
df = pd.read_sql_query('SELECT * FROM '+ table, engine)
|
|
stmt = "trigger == '" + key + "'"
|
|
temp = df.query(stmt)
|
|
result = temp.get("response")
|
|
|
|
#print(result)
|
|
i = len(temp.index.values)
|
|
|
|
if i == 1:
|
|
output = result[temp.index.values[0]]
|
|
pass
|
|
else:
|
|
output = "$$None$$"
|
|
return output
|
|
|
|
def get_data(self, tableName:str = "", key:str = ""):
|
|
pass
|
|
|
|
def insert_data(self, tableName:str = "", param:str = ""):
|
|
pass
|
|
|
|
def edit_data(self, tableName:str = "", key:str = "", param:str = ""):
|
|
pass
|
|
|
|
def delete_data(self, tableName:str = "", key:str = ""):
|
|
pass
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
db_connection = db_module()
|
|
db_connection.setup_engine() |