python-glowplug 0.3.6__tar.gz → 0.3.8__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-glowplug
3
- Version: 0.3.6
3
+ Version: 0.3.8
4
4
  Summary: A collection of utilities for common DB maintenance operations in SQLAlchemy
5
5
  Home-page: https://github.com/jnu/python-glowplug
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "python-glowplug"
3
- version = "0.3.6"
3
+ version = "0.3.8"
4
4
  description = "A collection of utilities for common DB maintenance operations in SQLAlchemy"
5
5
  authors = ["Joe Nudell <jnudell@hks.harvard.edu>"]
6
6
  readme = "README.md"
@@ -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
@@ -98,17 +98,27 @@ class DbDriver(ABC):
98
98
  """Get a sync engine."""
99
99
  return create_engine(self.sync_uri, echo=self.debug, **kwargs)
100
100
 
101
- @cached_property
102
- def async_session(self, **kwargs) -> AsyncSession:
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 sessionmaker(self.get_sync_engine(**kwargs), expire_on_commit=False)
121
+ return self.sync_session_with_args()
112
122
 
113
123
  @cached_property
114
124
  def alembic(self) -> AlembicCommandProxy:
@@ -53,7 +53,7 @@ class PostgresDriver(DbDriver):
53
53
  f"postgresql+asyncpg://{base_url}", echo=self.debug
54
54
  )
55
55
  async with engine.connect() as conn:
56
- await conn.execute(f"CREATE DATABASE {db_name}")
56
+ await conn.execute(text(f"CREATE DATABASE {db_name}"))
57
57
  await engine.dispose()
58
58
 
59
59
  @property
File without changes