|
1 | | -from ddcDatabases.core.operations import DBUtils, DBUtilsAsync |
2 | | -from ddcDatabases.core.persistent import PersistentConnectionConfig, close_all_persistent_connections |
3 | | -from ddcDatabases.sqlite import ( |
4 | | - Sqlite, |
5 | | - SqliteConnRetryConfig, |
6 | | - SqliteOpRetryConfig, |
7 | | - SqliteSessionConfig, |
8 | | -) |
9 | | -from importlib.metadata import version |
10 | 1 | import logging |
11 | | -from typing import Literal, NamedTuple |
| 2 | +from .core.operations import DBUtils, DBUtilsAsync |
| 3 | +from .core.persistent import PersistentConnectionConfig, close_all_persistent_connections |
| 4 | +from importlib.metadata import version |
12 | 5 |
|
13 | 6 | __all__ = [ |
14 | 7 | "DBUtils", |
15 | 8 | "DBUtilsAsync", |
16 | 9 | "PersistentConnectionConfig", |
17 | | - "Sqlite", |
18 | | - "SqliteConnRetryConfig", |
19 | | - "SqliteOpRetryConfig", |
20 | | - "SqliteSessionConfig", |
21 | 10 | "close_all_persistent_connections", |
22 | 11 | ] |
23 | 12 |
|
24 | 13 | # Conditional imports based on available dependencies |
| 14 | +try: |
| 15 | + from .core.settings import clear_sqlite_settings_cache, get_sqlite_settings |
| 16 | + from .sqlite import ( |
| 17 | + Sqlite, |
| 18 | + SqliteConnRetryConfig, |
| 19 | + SqliteOpRetryConfig, |
| 20 | + SqliteSessionConfig, |
| 21 | + ) |
| 22 | + |
| 23 | + __all__ += [ |
| 24 | + "Sqlite", |
| 25 | + "SqliteConnRetryConfig", |
| 26 | + "SqliteOpRetryConfig", |
| 27 | + "SqliteSessionConfig", |
| 28 | + "clear_sqlite_settings_cache", |
| 29 | + "get_sqlite_settings", |
| 30 | + ] |
| 31 | +except ImportError: |
| 32 | + pass |
| 33 | + |
25 | 34 | try: |
26 | 35 | from .core.persistent import MongoDBPersistent |
| 36 | + from .core.settings import clear_mongodb_settings_cache, get_mongodb_settings |
27 | 37 | from .mongodb import ( |
28 | 38 | MongoDB, |
29 | 39 | MongoDBConnectionConfig, |
|
41 | 51 | "MongoDBPersistent", |
42 | 52 | "MongoDBQueryConfig", |
43 | 53 | "MongoDBTLSConfig", |
| 54 | + "clear_mongodb_settings_cache", |
| 55 | + "get_mongodb_settings", |
44 | 56 | ] |
45 | 57 | except ImportError: |
46 | 58 | pass |
47 | 59 |
|
48 | 60 | try: |
49 | 61 | from .core.persistent import MSSQLPersistent |
| 62 | + from .core.settings import clear_mssql_settings_cache, get_mssql_settings |
50 | 63 | from .mssql import ( |
51 | 64 | MSSQL, |
52 | 65 | MSSQLConnectionConfig, |
|
66 | 79 | "MSSQLPoolConfig", |
67 | 80 | "MSSQLSessionConfig", |
68 | 81 | "MSSQLSSLConfig", |
| 82 | + "clear_mssql_settings_cache", |
| 83 | + "get_mssql_settings", |
69 | 84 | ] |
70 | 85 | except ImportError: |
71 | 86 | pass |
72 | 87 |
|
73 | 88 | try: |
74 | 89 | from .core.persistent import MySQLPersistent |
| 90 | + from .core.settings import clear_mysql_settings_cache, get_mysql_settings |
75 | 91 | from .mysql import ( |
76 | 92 | MySQL, |
77 | 93 | MySQLConnectionConfig, |
|
91 | 107 | MariaDBPoolConfig = MySQLPoolConfig |
92 | 108 | MariaDBSessionConfig = MySQLSessionConfig |
93 | 109 | MariaDBSSLConfig = MySQLSSLConfig |
| 110 | + clear_mariadb_settings_cache = clear_mysql_settings_cache |
| 111 | + get_mariadb_settings = get_mysql_settings |
94 | 112 |
|
95 | 113 | __all__ += [ |
96 | 114 | "MySQL", |
|
101 | 119 | "MySQLPoolConfig", |
102 | 120 | "MySQLSessionConfig", |
103 | 121 | "MySQLSSLConfig", |
| 122 | + "clear_mysql_settings_cache", |
| 123 | + "get_mysql_settings", |
104 | 124 | # MariaDB aliases |
105 | 125 | "MariaDB", |
106 | 126 | "MariaDBConnectionConfig", |
|
110 | 130 | "MariaDBPoolConfig", |
111 | 131 | "MariaDBSessionConfig", |
112 | 132 | "MariaDBSSLConfig", |
| 133 | + "clear_mariadb_settings_cache", |
| 134 | + "get_mariadb_settings", |
113 | 135 | ] |
114 | 136 | except ImportError: |
115 | 137 | pass |
116 | 138 |
|
117 | 139 | try: |
118 | 140 | from .core.persistent import OraclePersistent |
| 141 | + from .core.settings import clear_oracle_settings_cache, get_oracle_settings |
119 | 142 | from .oracle import ( |
120 | 143 | Oracle, |
121 | 144 | OracleConnectionConfig, |
|
135 | 158 | "OraclePoolConfig", |
136 | 159 | "OracleSessionConfig", |
137 | 160 | "OracleSSLConfig", |
| 161 | + "clear_oracle_settings_cache", |
| 162 | + "get_oracle_settings", |
138 | 163 | ] |
139 | 164 | except ImportError: |
140 | 165 | pass |
141 | 166 |
|
142 | 167 | try: |
143 | 168 | from .core.persistent import PostgreSQLPersistent |
| 169 | + from .core.settings import clear_postgresql_settings_cache, get_postgresql_settings |
144 | 170 | from .postgresql import ( |
145 | 171 | PostgreSQL, |
146 | 172 | PostgreSQLConnectionConfig, |
|
160 | 186 | "PostgreSQLPoolConfig", |
161 | 187 | "PostgreSQLSessionConfig", |
162 | 188 | "PostgreSQLSSLConfig", |
| 189 | + "clear_postgresql_settings_cache", |
| 190 | + "get_postgresql_settings", |
163 | 191 | ] |
164 | 192 | except ImportError: |
165 | 193 | pass |
|
170 | 198 | __email__ = "danieldcsta@gmail.com>" |
171 | 199 | __license__ = "MIT" |
172 | 200 | __copyright__ = "Copyright 2024-present DDC Softwares" |
173 | | -_req_python_version = (3, 12, 0) |
174 | | - |
175 | | - |
176 | | -try: |
177 | | - _version = tuple(int(x) for x in version(__title__).split(".")) |
178 | | -except ModuleNotFoundError: |
179 | | - _version = (0, 0, 0) |
180 | | - |
181 | | - |
182 | | -class VersionInfo(NamedTuple): |
183 | | - major: int |
184 | | - minor: int |
185 | | - micro: int |
186 | | - releaselevel: Literal["alpha", "beta", "candidate", "final"] |
187 | | - serial: int |
188 | | - |
189 | | - |
190 | | -__version__ = _version |
191 | | -__version_info__: VersionInfo = VersionInfo( |
192 | | - major=__version__[0], |
193 | | - minor=__version__[1], |
194 | | - micro=__version__[2], |
195 | | - releaselevel="final", |
196 | | - serial=0, |
197 | | -) |
198 | | -__req_python_version__: VersionInfo = VersionInfo( |
199 | | - major=_req_python_version[0], |
200 | | - minor=_req_python_version[1], |
201 | | - micro=_req_python_version[2], |
202 | | - releaselevel="final", |
203 | | - serial=0, |
204 | | -) |
| 201 | +__version__ = version(__title__) |
205 | 202 |
|
206 | 203 | logging.getLogger(__name__).addHandler(logging.NullHandler()) |
207 | | - |
208 | | -del ( |
209 | | - logging, |
210 | | - NamedTuple, |
211 | | - Literal, |
212 | | - VersionInfo, |
213 | | - version, |
214 | | - _version, |
215 | | - _req_python_version, |
216 | | -) |
0 commit comments