mirror of
https://github.com/koloideal/Argenta.git
synced 2026-06-10 18:15:28 +03:00
28 lines
649 B
Python
28 lines
649 B
Python
import sqlite3
|
|
from sqlite3 import Connection
|
|
from typing import Iterable
|
|
|
|
from dishka import Provider, Scope, provide
|
|
|
|
from argenta import App, Orchestrator
|
|
|
|
|
|
class ConnectionProvider(Provider):
|
|
@provide(scope=Scope.REQUEST)
|
|
def new_connection(self) -> Iterable[Connection]:
|
|
conn = sqlite3.connect(":memory:")
|
|
yield conn
|
|
conn.close()
|
|
|
|
|
|
# 2. Create and configure App
|
|
app = App()
|
|
# ... you can add routers here ...
|
|
|
|
# 3. Create Orchestrator, passing our provider
|
|
orchestrator = Orchestrator(custom_providers=[ConnectionProvider()])
|
|
|
|
# 4. Start the application
|
|
if __name__ == "__main__":
|
|
orchestrator.run_repl(app)
|