ry-pg-utils 1.0.10__tar.gz → 1.0.14__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.
- {ry_pg_utils-1.0.10/src/ry_pg_utils.egg-info → ry_pg_utils-1.0.14}/PKG-INFO +1 -1
- ry_pg_utils-1.0.14/VERSION +1 -0
- {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.14}/src/ry_pg_utils/config.py +3 -3
- {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.14}/src/ry_pg_utils/connect.py +11 -13
- {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.14}/src/ry_pg_utils/ipc/channels.py +3 -3
- {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.14}/src/ry_pg_utils/updater.py +0 -2
- {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.14/src/ry_pg_utils.egg-info}/PKG-INFO +1 -1
- ry_pg_utils-1.0.10/VERSION +0 -1
- {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.14}/LICENSE +0 -0
- {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.14}/MANIFEST.in +0 -0
- {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.14}/README.md +0 -0
- {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.14}/packages/base_requirements.in +0 -0
- {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.14}/pyproject.toml +0 -0
- {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.14}/setup.cfg +0 -0
- {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.14}/setup.py +0 -0
- {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.14}/src/ry_pg_utils/__init__.py +0 -0
- {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.14}/src/ry_pg_utils/dynamic_table.py +0 -0
- {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.14}/src/ry_pg_utils/ipc/__init__.py +0 -0
- {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.14}/src/ry_pg_utils/notify_trigger.py +0 -0
- {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.14}/src/ry_pg_utils/parse_args.py +0 -0
- {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.14}/src/ry_pg_utils/pb_types/__init__.py +0 -0
- {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.14}/src/ry_pg_utils/pb_types/database_pb2.py +0 -0
- {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.14}/src/ry_pg_utils/pb_types/database_pb2.pyi +0 -0
- {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.14}/src/ry_pg_utils/pb_types/py.typed +0 -0
- {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.14}/src/ry_pg_utils/postgres_info.py +0 -0
- {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.14}/src/ry_pg_utils/py.typed +0 -0
- {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.14}/src/ry_pg_utils/tools/__init__.py +0 -0
- {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.14}/src/ry_pg_utils/tools/db_query.py +0 -0
- {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.14}/src/ry_pg_utils.egg-info/SOURCES.txt +0 -0
- {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.14}/src/ry_pg_utils.egg-info/dependency_links.txt +0 -0
- {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.14}/src/ry_pg_utils.egg-info/requires.txt +0 -0
- {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.14}/src/ry_pg_utils.egg-info/top_level.txt +0 -0
@@ -0,0 +1 @@
|
|
1
|
+
1.0.14
|
@@ -39,14 +39,14 @@ pg_config = Config(
|
|
39
39
|
postgres_db=os.getenv("POSTGRES_DB"),
|
40
40
|
postgres_user=os.getenv("POSTGRES_USER"),
|
41
41
|
postgres_password=os.getenv("POSTGRES_PASSWORD"),
|
42
|
-
do_publish_db=
|
42
|
+
do_publish_db=True,
|
43
43
|
use_local_db_only=True,
|
44
44
|
backend_id=(
|
45
45
|
os.getenv("POSTGRES_USER")
|
46
46
|
or f"{socket.gethostname()}_{socket.gethostbyname(socket.gethostname())}"
|
47
47
|
),
|
48
|
-
add_backend_to_all=
|
49
|
-
add_backend_to_tables=
|
48
|
+
add_backend_to_all=False,
|
49
|
+
add_backend_to_tables=False,
|
50
50
|
raise_on_use_before_init=True,
|
51
51
|
ssh_host=os.getenv("SSH_HOST"),
|
52
52
|
ssh_port=_ssh_port,
|
@@ -5,11 +5,10 @@ import threading
|
|
5
5
|
import typing as T
|
6
6
|
|
7
7
|
from ryutils import log
|
8
|
-
from sqlalchemy import
|
8
|
+
from sqlalchemy import String, create_engine, event
|
9
9
|
from sqlalchemy.engine.base import Engine
|
10
10
|
from sqlalchemy.exc import OperationalError
|
11
|
-
from sqlalchemy.orm import
|
12
|
-
from sqlalchemy.orm.decl_api import DeclarativeMeta
|
11
|
+
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column, scoped_session, sessionmaker
|
13
12
|
from sqlalchemy.orm.scoping import ScopedSession
|
14
13
|
from sqlalchemy_utils import database_exists
|
15
14
|
from tenacity import retry, stop_after_attempt, wait_exponential
|
@@ -22,20 +21,19 @@ BACKEND_ID_VARIABLE = "backend_id"
|
|
22
21
|
ENGINE: T.Dict[str, Engine] = {}
|
23
22
|
THREAD_SAFE_SESSION_FACTORY: T.Dict[str, ScopedSession] = {}
|
24
23
|
|
25
|
-
|
24
|
+
|
25
|
+
# Modern SQLAlchemy 2.0 declarative base
|
26
26
|
if config.pg_config.add_backend_to_all:
|
27
|
-
# Add any common fields here
|
28
|
-
class CommonBaseModel:
|
29
|
-
@declared_attr
|
30
|
-
def backend_id(cls: T.Any) -> Column: # pylint: disable=no-self-argument
|
31
|
-
return Column(String(256), nullable=False)
|
32
27
|
|
33
|
-
Base
|
28
|
+
class Base(DeclarativeBase):
|
29
|
+
"""Base class with automatic backend_id field."""
|
30
|
+
|
31
|
+
backend_id: Mapped[str] = mapped_column(String(256), nullable=False)
|
32
|
+
|
34
33
|
else:
|
35
|
-
Base = declarative_base(name="Base")
|
36
34
|
|
37
|
-
#
|
38
|
-
Base
|
35
|
+
class Base(DeclarativeBase): # type: ignore[no-redef]
|
36
|
+
"""Base class for all SQLAlchemy models."""
|
39
37
|
|
40
38
|
|
41
39
|
def get_table_name(
|
@@ -1,11 +1,11 @@
|
|
1
1
|
from ry_redis_bus.channels import Channel
|
2
2
|
|
3
|
-
from ry_pg_utils.pb_types.database_pb2 import DatabaseConfigPb # pylint: disable=no-name-in-module
|
4
3
|
from ry_pg_utils.pb_types.database_pb2 import ( # pylint: disable=no-name-in-module
|
5
4
|
DatabaseNotificationPb,
|
5
|
+
PostgresMessagePb,
|
6
6
|
)
|
7
7
|
|
8
8
|
# Channels
|
9
|
-
DATABASE_CHANNEL = Channel("DATABASE_CHANNEL",
|
10
|
-
DATABASE_CONFIG_CHANNEL = Channel("DATABASE_CONFIG_CHANNEL",
|
9
|
+
DATABASE_CHANNEL = Channel("DATABASE_CHANNEL", PostgresMessagePb)
|
10
|
+
DATABASE_CONFIG_CHANNEL = Channel("DATABASE_CONFIG_CHANNEL", PostgresMessagePb)
|
11
11
|
DATABASE_NOTIFY_CHANNEL = Channel("DATABASE_NOTIFY_CHANNEL", DatabaseNotificationPb)
|
@@ -45,14 +45,12 @@ def get_database_settings(
|
|
45
45
|
class DbUpdater(RedisClientBase):
|
46
46
|
do_publish_db: bool
|
47
47
|
postgres_info: PostgresInfo
|
48
|
-
backend_id: str
|
49
48
|
logging_error_db_callback: T.Callable[[str, str], None] | None
|
50
49
|
|
51
50
|
def __init__(
|
52
51
|
self,
|
53
52
|
redis_info: RedisInfo,
|
54
53
|
args: argparse.Namespace,
|
55
|
-
backend_id: str,
|
56
54
|
verbose: Verbose,
|
57
55
|
logging_error_db_callback: T.Callable[[str, str], None] | None = None,
|
58
56
|
):
|
ry_pg_utils-1.0.10/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.0.10
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|