mirror of
https://github.com/Xevion/contest-assistant.git
synced 2025-12-11 02:06:53 -06:00
basic bot setup
This commit is contained in:
27
contest/db.py
Normal file
27
contest/db.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import sqlite3
|
||||
|
||||
import aiosqlite
|
||||
|
||||
from contest import constants
|
||||
|
||||
|
||||
class ContestDatabase(object):
|
||||
"""
|
||||
A handler class for a SQLite3 database used by the bot with Async support.
|
||||
"""
|
||||
def __init__(self, conn: aiosqlite.Connection) -> None:
|
||||
self.db = conn
|
||||
|
||||
@classmethod
|
||||
async def create(cls) -> 'ContestDatabase':
|
||||
"""
|
||||
Constructs a ContestDatabase object connecting to the default database location with the proper connection settings.
|
||||
:return: A fully realized ContestDatabase object.
|
||||
"""
|
||||
conn = await aiosqlite.connect(constants.DATABASE, detect_types=sqlite3.PARSE_DELCTYPES)
|
||||
db = ContestDatabase(conn)
|
||||
await conn.commit()
|
||||
return db
|
||||
|
||||
async def is_setup(self):
|
||||
pass
|
||||
Reference in New Issue
Block a user