Removed bots.py and slurs.py and moved them into config.py. twitch_script_class.py has been updated to handle this added a test harness for twitch_script_class.py contains_url and contains_slur are both validated refactored contains_url to use a simple(ish) regex instead of an if cascade Let PEP8 do it's thing and reformat all the files. Removed bots.py and slurs.py and moved them into config.py. twitch_script_class.py has been updated to handle this added a test harness for twitch_script_class.py contains_url and contains_slur are both validated refactored contains_url to use a simple(ish) regex instead of an if cascade
62 lines
1.5 KiB
Python
62 lines
1.5 KiB
Python
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()
|