This should fix the database connection whitout a given database
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
4e06d454b2
commit
43ee84912e
@ -1,6 +1,7 @@
|
|||||||
from beanie import init_beanie
|
from beanie import init_beanie
|
||||||
from motor.motor_asyncio import AsyncIOMotorClient
|
from motor.motor_asyncio import AsyncIOMotorClient
|
||||||
from pydantic import BaseSettings, Field
|
from pydantic import BaseSettings, Field
|
||||||
|
import re
|
||||||
|
|
||||||
from models.request import Request
|
from models.request import Request
|
||||||
|
|
||||||
@ -18,5 +19,8 @@ class Settings(BaseSettings):
|
|||||||
|
|
||||||
|
|
||||||
async def initiate_database():
|
async def initiate_database():
|
||||||
client = AsyncIOMotorClient(Settings().DATABASE_URL)
|
parts = Settings().DATABASE_URL.split("/?")
|
||||||
|
db_url_with_database = parts[0] + "/requests?" + parts[1]
|
||||||
|
|
||||||
|
client = AsyncIOMotorClient(db_url_with_database)
|
||||||
await init_beanie(database=client.get_default_database(), document_models=[Request])
|
await init_beanie(database=client.get_default_database(), document_models=[Request])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user