summaryrefslogtreecommitdiff
path: root/__main__.py
diff options
context:
space:
mode:
authorBotond Hende <nettingman@gmail.com>2024-08-30 22:28:58 +0200
committerBotond Hende <nettingman@gmail.com>2024-08-30 22:28:58 +0200
commit9b686d79871c6f76b8ea36d8a8a43d3edb32def7 (patch)
tree6cc722707d37f9d70d9834921b705eb99b77d450 /__main__.py
parenta1de271e186a518932307bb7775f670d8ccd92f5 (diff)
agents are authenticated on space traders api
Diffstat (limited to '__main__.py')
-rw-r--r--__main__.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/__main__.py b/__main__.py
index 9dba645..9b23484 100644
--- a/__main__.py
+++ b/__main__.py
@@ -4,13 +4,15 @@ from typing import Annotated
from fastapi import FastAPI, Depends
from .apirouters import agents
-from .modules import database
+from .modules.database import cursor, conn
@asynccontextmanager
async def lifespan(app: FastAPI):
- database.cursor.execute(
- "CREATE TABLE IF NOT EXISTS agents(primary_key INTEGER PRIMARY KEY, callsign TEXT NOT NULL UNIQUE, token_hash TEXT NOT NULL)")
+ cursor.execute(
+ "CREATE TABLE IF NOT EXISTS agents(primary_key INTEGER PRIMARY KEY, callsign TEXT NOT NULL UNIQUE, token TEXT NOT NULL)")
+ conn.commit()
+ agents.load_agents_from_database()
yield