This commit is contained in:
2025-10-19 01:13:14 +03:00
parent 8324d3e5a2
commit b6e5c57b8a
6 changed files with 97 additions and 2 deletions
@@ -0,0 +1,12 @@
from sqlite3 import Connection
from argenta import Response, Router
from argenta.di import FromDishka
router = Router()
@router.command('connect')
def connect_handler(response: Response, connection: FromDishka[Connection]):
connection.execute('...')
@@ -0,0 +1,13 @@
import sqlite3
from sqlite3 import Connection
from typing import Iterable
from dishka import Provider, Scope, provide
class ConnectionProvider(Provider):
@provide(scope=Scope.REQUEST)
def new_connection(self) -> Iterable[Connection]:
conn = sqlite3.connect(":memory:")
yield conn
conn.close()
@@ -0,0 +1,3 @@
from argenta import Orchestrator
orchestrator = Orchestrator(custom_providers=[ConnectionProvider()])
@@ -0,0 +1,11 @@
from argenta import Response, Router
from argenta.orchestrator.argparser import ArgSpace
from argenta.di import FromDishka
router = Router()
@router.command('info')
def connect_handler(response: Response, argspace: FromDishka[ArgSpace]):
print(argspace.get_by_name('type'))