cromulant/database.py

23 lines
527 B
Python
Raw Normal View History

2024-07-18 06:51:11 +00:00
from __future__ import annotations
import sqlite3
from pathlib import Path
2024-07-18 07:20:36 +00:00
2024-07-18 06:51:11 +00:00
class Database:
connection: sqlite3.Connection
cursor: sqlite3.Cursor
@staticmethod
def prepare() -> None:
Database.connection = sqlite3.connect("ants.db")
Database.cursor = Database.connection.cursor()
@staticmethod
def create() -> None:
with Path("schema.sql").open("r") as file:
schema = file.read()
Database.cursor.executescript(schema)
2024-07-18 07:20:36 +00:00
Database.connection.commit()