refactor(project): move files into specific folders
This commit is contained in:
24
disclosures/util/db.py
Normal file
24
disclosures/util/db.py
Normal file
@@ -0,0 +1,24 @@
|
||||
import sqlite3
|
||||
|
||||
|
||||
class DB:
|
||||
def __init__(self, db_path, schema_path="schema.sql", seed_path="seed.sql"):
|
||||
self.con = sqlite3.connect(db_path)
|
||||
self.cur = self.con.cursor()
|
||||
with open(schema_path) as f:
|
||||
self.cur.executescript(f.read())
|
||||
|
||||
with open(seed_path) as f:
|
||||
self.cur.executescript(f.read())
|
||||
|
||||
def __del__(self):
|
||||
self.con.close()
|
||||
|
||||
def query(self, query, params=[]):
|
||||
self.cur.execute(query, params)
|
||||
return self.cur.fetchall()
|
||||
|
||||
def insertDisclosures(self, disclosures):
|
||||
sql = "INSERT INTO disclosures (member_id, filing_year, filing, link) VALUES (?, ?, ?, ?)"
|
||||
self.cur.executemany(sql, disclosures)
|
||||
self.con.commit()
|
||||
11
disclosures/util/telegram_bot.py
Normal file
11
disclosures/util/telegram_bot.py
Normal file
@@ -0,0 +1,11 @@
|
||||
import telegram
|
||||
|
||||
class Telegram:
|
||||
def __init__(self, token, channel_id):
|
||||
self.token = token
|
||||
self.bot = telegram.Bot(token=token)
|
||||
self.channel_id = channel_id
|
||||
|
||||
|
||||
async def send_message(self, message: str):
|
||||
await self.bot.send_message(chat_id=self.channel_id, text=message)
|
||||
Reference in New Issue
Block a user