29 lines
810 B
Python
29 lines
810 B
Python
import aiosqlite
|
|
|
|
class Database:
|
|
def __init__(self):
|
|
self.conn = None
|
|
|
|
async def connect(self):
|
|
if self.conn is None:
|
|
self.conn = await aiosqlite.connect("FemBot.db")
|
|
|
|
try:
|
|
await self.conn.execute("""
|
|
CREATE TABLE IF NOT EXISTS test (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
message TEXT NOT NULL
|
|
)
|
|
""")
|
|
|
|
await self.conn.commit()
|
|
print("Table check/creation completed successfully.")
|
|
|
|
except aiosqlite.Error as e:
|
|
print(f"Failed to check/creation table: {e}")
|
|
|
|
return self.conn
|
|
|
|
async def close(self):
|
|
if self.conn:
|
|
await self.conn.close() |