ry-pg-utils 1.0.10__tar.gz → 1.0.11__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.
Files changed (32) hide show
  1. {ry_pg_utils-1.0.10/src/ry_pg_utils.egg-info → ry_pg_utils-1.0.11}/PKG-INFO +1 -1
  2. ry_pg_utils-1.0.11/VERSION +1 -0
  3. {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.11}/src/ry_pg_utils/connect.py +11 -13
  4. {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.11}/src/ry_pg_utils/ipc/channels.py +3 -3
  5. {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.11}/src/ry_pg_utils/updater.py +0 -2
  6. {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.11/src/ry_pg_utils.egg-info}/PKG-INFO +1 -1
  7. ry_pg_utils-1.0.10/VERSION +0 -1
  8. {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.11}/LICENSE +0 -0
  9. {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.11}/MANIFEST.in +0 -0
  10. {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.11}/README.md +0 -0
  11. {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.11}/packages/base_requirements.in +0 -0
  12. {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.11}/pyproject.toml +0 -0
  13. {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.11}/setup.cfg +0 -0
  14. {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.11}/setup.py +0 -0
  15. {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.11}/src/ry_pg_utils/__init__.py +0 -0
  16. {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.11}/src/ry_pg_utils/config.py +0 -0
  17. {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.11}/src/ry_pg_utils/dynamic_table.py +0 -0
  18. {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.11}/src/ry_pg_utils/ipc/__init__.py +0 -0
  19. {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.11}/src/ry_pg_utils/notify_trigger.py +0 -0
  20. {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.11}/src/ry_pg_utils/parse_args.py +0 -0
  21. {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.11}/src/ry_pg_utils/pb_types/__init__.py +0 -0
  22. {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.11}/src/ry_pg_utils/pb_types/database_pb2.py +0 -0
  23. {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.11}/src/ry_pg_utils/pb_types/database_pb2.pyi +0 -0
  24. {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.11}/src/ry_pg_utils/pb_types/py.typed +0 -0
  25. {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.11}/src/ry_pg_utils/postgres_info.py +0 -0
  26. {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.11}/src/ry_pg_utils/py.typed +0 -0
  27. {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.11}/src/ry_pg_utils/tools/__init__.py +0 -0
  28. {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.11}/src/ry_pg_utils/tools/db_query.py +0 -0
  29. {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.11}/src/ry_pg_utils.egg-info/SOURCES.txt +0 -0
  30. {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.11}/src/ry_pg_utils.egg-info/dependency_links.txt +0 -0
  31. {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.11}/src/ry_pg_utils.egg-info/requires.txt +0 -0
  32. {ry_pg_utils-1.0.10 → ry_pg_utils-1.0.11}/src/ry_pg_utils.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ry-pg-utils
3
- Version: 1.0.10
3
+ Version: 1.0.11
4
4
  Summary: Utility functions for PostgreSQL
5
5
  Author: Ross Yeager
6
6
  Author-email: ryeager12@email.com
@@ -0,0 +1 @@
1
+ 1.0.11
@@ -5,11 +5,10 @@ import threading
5
5
  import typing as T
6
6
 
7
7
  from ryutils import log
8
- from sqlalchemy import Column, String, create_engine, event
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 declarative_base, declared_attr, scoped_session, sessionmaker
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
- # Base class with optional backend_id field
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 = declarative_base(name="Base", cls=CommonBaseModel)
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
- # Add type annotation for Base
38
- Base: DeclarativeMeta # type: ignore
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", DatabaseConfigPb)
10
- DATABASE_CONFIG_CHANNEL = Channel("DATABASE_CONFIG_CHANNEL", DatabaseConfigPb)
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
  ):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ry-pg-utils
3
- Version: 1.0.10
3
+ Version: 1.0.11
4
4
  Summary: Utility functions for PostgreSQL
5
5
  Author: Ross Yeager
6
6
  Author-email: ryeager12@email.com
@@ -1 +0,0 @@
1
- 1.0.10
File without changes
File without changes
File without changes
File without changes
File without changes