python-glowplug 0.3.5__tar.gz → 0.3.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python_glowplug-0.3.5 → python_glowplug-0.3.7}/PKG-INFO +1 -1
- {python_glowplug-0.3.5 → python_glowplug-0.3.7}/pyproject.toml +1 -1
- {python_glowplug-0.3.5 → python_glowplug-0.3.7}/src/glowplug/driver/base.py +19 -9
- {python_glowplug-0.3.5 → python_glowplug-0.3.7}/LICENSE +0 -0
- {python_glowplug-0.3.5 → python_glowplug-0.3.7}/README.md +0 -0
- {python_glowplug-0.3.5 → python_glowplug-0.3.7}/src/glowplug/__init__.py +0 -0
- {python_glowplug-0.3.5 → python_glowplug-0.3.7}/src/glowplug/config/__init__.py +0 -0
- {python_glowplug-0.3.5 → python_glowplug-0.3.7}/src/glowplug/driver/__init__.py +0 -0
- {python_glowplug-0.3.5 → python_glowplug-0.3.7}/src/glowplug/driver/mssql.py +0 -0
- {python_glowplug-0.3.5 → python_glowplug-0.3.7}/src/glowplug/driver/pg.py +0 -0
- {python_glowplug-0.3.5 → python_glowplug-0.3.7}/src/glowplug/driver/sqlite.py +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from abc import ABC, abstractmethod
|
|
2
|
-
from functools import cached_property
|
|
2
|
+
from functools import cached_property, cache
|
|
3
3
|
from typing import Any, List
|
|
4
4
|
|
|
5
5
|
import alembic
|
|
@@ -90,25 +90,35 @@ class DbDriver(ABC):
|
|
|
90
90
|
await conn.run_sync(base.metadata.create_all)
|
|
91
91
|
await engine.dispose()
|
|
92
92
|
|
|
93
|
-
def get_async_engine(self) -> AsyncEngine:
|
|
93
|
+
def get_async_engine(self, **kwargs) -> AsyncEngine:
|
|
94
94
|
"""Get an async engine."""
|
|
95
|
-
return create_async_engine(self.async_uri, echo=self.debug)
|
|
95
|
+
return create_async_engine(self.async_uri, echo=self.debug, **kwargs)
|
|
96
96
|
|
|
97
|
-
def get_sync_engine(self) -> Engine:
|
|
97
|
+
def get_sync_engine(self, **kwargs) -> Engine:
|
|
98
98
|
"""Get a sync engine."""
|
|
99
|
-
return create_engine(self.sync_uri, echo=self.debug)
|
|
99
|
+
return create_engine(self.sync_uri, echo=self.debug, **kwargs)
|
|
100
100
|
|
|
101
|
-
@
|
|
102
|
-
def
|
|
103
|
-
"""Get an async session."""
|
|
101
|
+
@cache
|
|
102
|
+
def async_session_with_args(self, **kwargs) -> AsyncSession:
|
|
103
|
+
"""Get an async session with arguments."""
|
|
104
104
|
return async_sessionmaker(
|
|
105
105
|
self.get_async_engine(**kwargs), expire_on_commit=False
|
|
106
106
|
)
|
|
107
107
|
|
|
108
|
+
@cached_property
|
|
109
|
+
def async_session(self) -> AsyncSession:
|
|
110
|
+
"""Get an async session."""
|
|
111
|
+
return self.async_session_with_args()
|
|
112
|
+
|
|
113
|
+
@cache
|
|
114
|
+
def sync_session_with_args(self, **kwargs) -> Session:
|
|
115
|
+
"""Get a sync session with arguments."""
|
|
116
|
+
return sessionmaker(self.get_sync_engine(**kwargs), expire_on_commit=False)
|
|
117
|
+
|
|
108
118
|
@cached_property
|
|
109
119
|
def sync_session(self, **kwargs) -> Session:
|
|
110
120
|
"""Get a sync session."""
|
|
111
|
-
return
|
|
121
|
+
return self.sync_session_with_args()
|
|
112
122
|
|
|
113
123
|
@cached_property
|
|
114
124
|
def alembic(self) -> AlembicCommandProxy:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|