deev 1.2.2__tar.gz → 1.2.3__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 (49) hide show
  1. {deev-1.2.2/src/deev.egg-info → deev-1.2.3}/PKG-INFO +1 -1
  2. {deev-1.2.2 → deev-1.2.3}/pyproject.toml +1 -1
  3. {deev-1.2.2 → deev-1.2.3}/src/deev/__init__.py +2 -2
  4. {deev-1.2.2 → deev-1.2.3}/src/deev/common/ConnectionString.py +28 -0
  5. {deev-1.2.2 → deev-1.2.3}/src/deev/utils.py +34 -5
  6. {deev-1.2.2 → deev-1.2.3/src/deev.egg-info}/PKG-INFO +1 -1
  7. {deev-1.2.2 → deev-1.2.3}/LICENSE +0 -0
  8. {deev-1.2.2 → deev-1.2.3}/README.md +0 -0
  9. {deev-1.2.2 → deev-1.2.3}/setup.cfg +0 -0
  10. {deev-1.2.2 → deev-1.2.3}/src/deev/_ImmutableMixin.py +0 -0
  11. {deev-1.2.2 → deev-1.2.3}/src/deev/_MigrationData.py +0 -0
  12. {deev-1.2.2 → deev-1.2.3}/src/deev/common/DbConnection.py +0 -0
  13. {deev-1.2.2 → deev-1.2.3}/src/deev/common/DbContext.py +0 -0
  14. {deev-1.2.2 → deev-1.2.3}/src/deev/common/DbCursor.py +0 -0
  15. {deev-1.2.2 → deev-1.2.3}/src/deev/common/DbError.py +0 -0
  16. {deev-1.2.2 → deev-1.2.3}/src/deev/common/DbMigrator.py +0 -0
  17. {deev-1.2.2 → deev-1.2.3}/src/deev/common/DbParams.py +0 -0
  18. {deev-1.2.2 → deev-1.2.3}/src/deev/common/DbTableAdapter.py +0 -0
  19. {deev-1.2.2 → deev-1.2.3}/src/deev/common/DbTransactionContext.py +0 -0
  20. {deev-1.2.2 → deev-1.2.3}/src/deev/common/DbTypeMapper.py +0 -0
  21. {deev-1.2.2 → deev-1.2.3}/src/deev/common/__init__.py +0 -0
  22. {deev-1.2.2 → deev-1.2.3}/src/deev/db_migrate.py +0 -0
  23. {deev-1.2.2 → deev-1.2.3}/src/deev/entities.py +0 -0
  24. {deev-1.2.2 → deev-1.2.3}/src/deev/mongodb/MongoProxyConnection.py +0 -0
  25. {deev-1.2.2 → deev-1.2.3}/src/deev/mongodb/MongoProxyCursor.py +0 -0
  26. {deev-1.2.2 → deev-1.2.3}/src/deev/mongodb/MongoTableAdapter.py +0 -0
  27. {deev-1.2.2 → deev-1.2.3}/src/deev/mongodb/MongoTransactionContext.py +0 -0
  28. {deev-1.2.2 → deev-1.2.3}/src/deev/mongodb/MongoTypeMapper.py +0 -0
  29. {deev-1.2.2 → deev-1.2.3}/src/deev/mongodb/__init__.py +0 -0
  30. {deev-1.2.2 → deev-1.2.3}/src/deev/mysql/MysqlProxyConnection.py +0 -0
  31. {deev-1.2.2 → deev-1.2.3}/src/deev/mysql/MysqlProxyCursor.py +0 -0
  32. {deev-1.2.2 → deev-1.2.3}/src/deev/mysql/MysqlTableAdapter.py +0 -0
  33. {deev-1.2.2 → deev-1.2.3}/src/deev/mysql/MysqlTransactionContext.py +0 -0
  34. {deev-1.2.2 → deev-1.2.3}/src/deev/mysql/MysqlTypeMapper.py +0 -0
  35. {deev-1.2.2 → deev-1.2.3}/src/deev/mysql/__init__.py +0 -0
  36. {deev-1.2.2 → deev-1.2.3}/src/deev/py.typed +0 -0
  37. {deev-1.2.2 → deev-1.2.3}/src/deev/sqlite/SqliteProxyConnection.py +0 -0
  38. {deev-1.2.2 → deev-1.2.3}/src/deev/sqlite/SqliteProxyCursor.py +0 -0
  39. {deev-1.2.2 → deev-1.2.3}/src/deev/sqlite/SqliteTableAdapter.py +0 -0
  40. {deev-1.2.2 → deev-1.2.3}/src/deev/sqlite/SqliteTransactionContext.py +0 -0
  41. {deev-1.2.2 → deev-1.2.3}/src/deev/sqlite/SqliteTypeMapper.py +0 -0
  42. {deev-1.2.2 → deev-1.2.3}/src/deev/sqlite/__init__.py +0 -0
  43. {deev-1.2.2 → deev-1.2.3}/src/deev/translation.py +0 -0
  44. {deev-1.2.2 → deev-1.2.3}/src/deev/validation.py +0 -0
  45. {deev-1.2.2 → deev-1.2.3}/src/deev.egg-info/SOURCES.txt +0 -0
  46. {deev-1.2.2 → deev-1.2.3}/src/deev.egg-info/dependency_links.txt +0 -0
  47. {deev-1.2.2 → deev-1.2.3}/src/deev.egg-info/entry_points.txt +0 -0
  48. {deev-1.2.2 → deev-1.2.3}/src/deev.egg-info/requires.txt +0 -0
  49. {deev-1.2.2 → deev-1.2.3}/src/deev.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: deev
3
- Version: 1.2.2
3
+ Version: 1.2.3
4
4
  Summary: ..an entity framework for Python.
5
5
  Author-email: Shaun Wilson <mrshaunwilson@msn.com>
6
6
  License-Expression: MIT
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "deev"
3
- version = "1.2.2"
3
+ version = "1.2.3"
4
4
  description = "..an entity framework for Python."
5
5
  keywords = ["DB", "database", "entity framework", "mapper"]
6
6
  authors = [
@@ -11,8 +11,8 @@ from .utils import connect
11
11
  from . import common, entities, mongodb, mysql, translation, utils, validation
12
12
 
13
13
 
14
- __version__ = '1.2.2'
15
- __commit__ = '96178a5'
14
+ __version__ = '1.2.3'
15
+ __commit__ = '8a79d66'
16
16
  __all__ = [
17
17
  '__version__', '__commit__',
18
18
  'ConnectionString',
@@ -16,6 +16,8 @@ class ConnectionString:
16
16
  __user: Optional[str]
17
17
  __password: Optional[str]
18
18
  __provider: Optional[str]
19
+ __connect_timeout: Optional[int]
20
+ __command_timeout: Optional[int]
19
21
 
20
22
  def __init__(
21
23
  self,
@@ -26,6 +28,8 @@ class ConnectionString:
26
28
  self.__user = None
27
29
  self.__password = None
28
30
  self.__provider = None
31
+ self.__connect_timeout = None
32
+ self.__command_timeout = None
29
33
  if connection_str is not None:
30
34
  self.parse(connection_str)
31
35
 
@@ -41,6 +45,10 @@ class ConnectionString:
41
45
  parts.append(f'PWD={self.password}')
42
46
  if self.provider is not None:
43
47
  parts.append(f'Provider={self.provider}')
48
+ if self.connect_timeout is not None:
49
+ parts.append(f'Connection Timeout={self.connect_timeout}')
50
+ if self.command_timeout is not None:
51
+ parts.append(f'Command Timeout={self.command_timeout}')
44
52
  return ';'.join(parts)
45
53
 
46
54
  @property
@@ -83,6 +91,22 @@ class ConnectionString:
83
91
  def provider(self, value: Optional[str]):
84
92
  self.__provider = value
85
93
 
94
+ @property
95
+ def connect_timeout(self) -> Optional[int]:
96
+ return self.__connect_timeout
97
+
98
+ @connect_timeout.setter
99
+ def connect_timeout(self, value: Optional[int]):
100
+ self.__connect_timeout = value
101
+
102
+ @property
103
+ def command_timeout(self) -> Optional[int]:
104
+ return self.__command_timeout
105
+
106
+ @command_timeout.setter
107
+ def command_timeout(self, value: Optional[int]):
108
+ self.__command_timeout = value
109
+
86
110
  def parse(self, connectionstring: Optional[str]) -> ConnectionString:
87
111
  parts = (
88
112
  []
@@ -102,6 +126,10 @@ class ConnectionString:
102
126
  self.password = value
103
127
  case 'provider':
104
128
  self.provider = value
129
+ case 'connection timeout':
130
+ self.connect_timeout = int(value)
131
+ case 'command timeout':
132
+ self.command_timeout = int(value)
105
133
  return self
106
134
 
107
135
 
@@ -14,12 +14,28 @@ from .common.DbTableAdapter import DbTableAdapter
14
14
  from .common.DbTransactionContext import DbTransactionContext
15
15
 
16
16
 
17
- def connect(connectionstring: ConnectionString | str) -> DbConnection:
17
+ def connect(
18
+ connectionstring: ConnectionString | str,
19
+ *,
20
+ connect_timeout: int = 3,
21
+ command_timeout: int = 9,
22
+ ) -> DbConnection:
18
23
  """
19
24
  Create a PEP 249 Connection to a database, given *connectionstring*.
25
+
26
+ Args:
27
+ connectionstring: A DSN string or :class:`ConnectionString` object.
28
+ connect_timeout: Connection timeout in seconds (if the provider supports it).
29
+ Only used when *connectionstring* does not specify
30
+ ``Connection Timeout``.
31
+ command_timeout: Command/operation timeout in seconds (if the provider supports it).
32
+ Only used when *connectionstring* does not specify
33
+ ``Command Timeout``.
20
34
  """
21
35
  if isinstance(connectionstring, str):
22
36
  connectionstring = ConnectionString(connectionstring)
37
+ effective_connect_timeout = connectionstring.connect_timeout if connectionstring.connect_timeout is not None else connect_timeout
38
+ effective_command_timeout = connectionstring.command_timeout if connectionstring.command_timeout is not None else command_timeout
23
39
  match connectionstring.provider:
24
40
  case 'mongodb':
25
41
  from deev.mongodb.MongoProxyConnection import MongoProxyConnection
@@ -28,7 +44,11 @@ def connect(connectionstring: ConnectionString | str) -> DbConnection:
28
44
  raise DbError(f'ConnectionString is missing `database` component: {connectionstring}')
29
45
  mongo_uri = f'mongodb://{connectionstring.user}:{connectionstring.password}@{connectionstring.server}/{connectionstring.database}'
30
46
  return MongoProxyConnection(
31
- pymongo.MongoClient(mongo_uri),
47
+ pymongo.MongoClient(
48
+ mongo_uri,
49
+ serverSelectionTimeoutMS=effective_connect_timeout * 1000,
50
+ socketTimeoutMS=effective_command_timeout * 1000,
51
+ ),
32
52
  database_name=connectionstring.database
33
53
  )
34
54
  case 'mysql.connector' | 'mysql':
@@ -38,14 +58,23 @@ def connect(connectionstring: ConnectionString | str) -> DbConnection:
38
58
  raise DbError(f'ConnectionString is missing `server` component: {connectionstring}')
39
59
  parts = connectionstring.server.split(':')
40
60
  host_name, port_number = (parts[0], int(parts[1])) if len(parts) == 2 else (parts[0], 3306)
41
- return MysqlProxyConnection(mysql.connector.connect(
61
+ conn = mysql.connector.connect(
42
62
  host=host_name,
43
63
  port=port_number,
44
64
  user=connectionstring.user,
45
65
  password=connectionstring.password,
46
66
  database=connectionstring.database,
47
- use_pure=True
48
- ))
67
+ use_pure=True,
68
+ connection_timeout=effective_connect_timeout,
69
+ read_timeout=effective_command_timeout,
70
+ write_timeout=effective_command_timeout
71
+ )
72
+ if effective_command_timeout is not None:
73
+ cur = conn.cursor()
74
+ cur.execute(f'SET SESSION wait_timeout={effective_command_timeout}')
75
+ cur.close()
76
+ conn.commit()
77
+ return MysqlProxyConnection(conn)
49
78
  case 'sqlite3' | 'sqlite':
50
79
  from deev.sqlite.SqliteProxyConnection import SqliteProxyConnection
51
80
  import sqlite3
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: deev
3
- Version: 1.2.2
3
+ Version: 1.2.3
4
4
  Summary: ..an entity framework for Python.
5
5
  Author-email: Shaun Wilson <mrshaunwilson@msn.com>
6
6
  License-Expression: MIT
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