fast-feature-storage-postgresql 0.0.1__py3-none-any.whl
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.
- fast_feature/storage/postgresql/__init__.py +5 -0
- fast_feature/storage/postgresql/py.typed +0 -0
- fast_feature/storage/postgresql/storage.py +35 -0
- fast_feature_storage_postgresql-0.0.1.dist-info/METADATA +19 -0
- fast_feature_storage_postgresql-0.0.1.dist-info/RECORD +6 -0
- fast_feature_storage_postgresql-0.0.1.dist-info/WHEEL +4 -0
|
File without changes
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from sqlalchemy.ext.asyncio import AsyncEngine, async_sessionmaker, create_async_engine
|
|
4
|
+
|
|
5
|
+
from fast_feature.storage.sqlalchemy import Schema, SqlAlchemyFlagRepository
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class PostgresStorage:
|
|
9
|
+
"""Wires a PostgreSQL (asyncpg) engine to the SQLAlchemy repository."""
|
|
10
|
+
|
|
11
|
+
def __init__(self, engine: AsyncEngine) -> None:
|
|
12
|
+
self._engine = engine
|
|
13
|
+
self._session_factory = async_sessionmaker(engine, expire_on_commit=False)
|
|
14
|
+
|
|
15
|
+
@classmethod
|
|
16
|
+
def from_dsn(cls, dsn: str, **engine_options: object) -> PostgresStorage:
|
|
17
|
+
return cls(create_async_engine(cls._normalize_dsn(dsn), **engine_options))
|
|
18
|
+
|
|
19
|
+
@property
|
|
20
|
+
def engine(self) -> AsyncEngine:
|
|
21
|
+
return self._engine
|
|
22
|
+
|
|
23
|
+
@property
|
|
24
|
+
def repository(self) -> SqlAlchemyFlagRepository:
|
|
25
|
+
return SqlAlchemyFlagRepository(self._session_factory)
|
|
26
|
+
|
|
27
|
+
async def create_schema(self) -> None:
|
|
28
|
+
await Schema.create_all(self._engine)
|
|
29
|
+
|
|
30
|
+
@staticmethod
|
|
31
|
+
def _normalize_dsn(dsn: str) -> str:
|
|
32
|
+
for prefix in ("postgresql://", "postgres://"):
|
|
33
|
+
if dsn.startswith(prefix):
|
|
34
|
+
return f"postgresql+asyncpg://{dsn[len(prefix) :]}"
|
|
35
|
+
return dsn
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fast-feature-storage-postgresql
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: PostgreSQL storage backend for fast-feature (asyncpg).
|
|
5
|
+
Author: byunjuneseok
|
|
6
|
+
Author-email: byunjuneseok <byunjuneseok@gmail.com>
|
|
7
|
+
License-Expression: Apache-2.0
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Framework :: AsyncIO
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Typing :: Typed
|
|
17
|
+
Requires-Dist: fast-feature-storage-sqlalchemy==0.0.1
|
|
18
|
+
Requires-Dist: asyncpg>=0.29
|
|
19
|
+
Requires-Python: >=3.10
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
fast_feature/storage/postgresql/__init__.py,sha256=w_sr4Zvo5KLR0knI6mu9HhNYZUuMJd5Tg8I2l8hL1Vo,104
|
|
2
|
+
fast_feature/storage/postgresql/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
fast_feature/storage/postgresql/storage.py,sha256=rFFv-jbmi3_SnLNE_9zS5hu_gI6_LA3KNW8EdqjF0O8,1193
|
|
4
|
+
fast_feature_storage_postgresql-0.0.1.dist-info/WHEEL,sha256=8ZlpUMJ7mlDirmlHRhDirEx_nPnARrwDjeE92mlk68E,81
|
|
5
|
+
fast_feature_storage_postgresql-0.0.1.dist-info/METADATA,sha256=DC3xoKPBsm3_gYHUru4U_XVv1MTRqkIcnW7RaS7wBPA,766
|
|
6
|
+
fast_feature_storage_postgresql-0.0.1.dist-info/RECORD,,
|