atoti-client-jdbc 0.9.0__py3-none-any.whl
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.
- atoti_client_jdbc-0.9.0.dist-info/METADATA +24 -0
- atoti_client_jdbc-0.9.0.dist-info/RECORD +9 -0
- atoti_client_jdbc-0.9.0.dist-info/WHEEL +4 -0
- atoti_jdbc/__init__.py +5 -0
- atoti_jdbc/_infer_driver.py +35 -0
- atoti_jdbc/_jdbc_ping_discovery_protocol.py +62 -0
- atoti_jdbc/driver.py +42 -0
- atoti_jdbc/py.typed +0 -0
- atoti_jdbc/user_content_storage_config.py +59 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: atoti-client-jdbc
|
|
3
|
+
Version: 0.9.0
|
|
4
|
+
Summary: Code to interact with databases through JDBC
|
|
5
|
+
Home-page: https://www.atoti.io
|
|
6
|
+
License: Proprietary
|
|
7
|
+
Keywords: atoti,database,jdbc,sql
|
|
8
|
+
Author: ActiveViam
|
|
9
|
+
Author-email: dev@atoti.io
|
|
10
|
+
Requires-Python: >=3.10
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: License :: Free To Use But Restricted
|
|
13
|
+
Classifier: License :: Other/Proprietary License
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Typing :: Typed
|
|
20
|
+
Requires-Dist: atoti-client (==0.9.0)
|
|
21
|
+
Requires-Dist: pydantic (>=2.6.0)
|
|
22
|
+
Requires-Dist: typing-extensions (>=4.6.1)
|
|
23
|
+
Project-URL: Bug Tracker, https://github.com/atoti/atoti/issues
|
|
24
|
+
Project-URL: Documentation, https://docs.atoti.io/0.9.0/api/atoti_jdbc.html
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
atoti_jdbc/__init__.py,sha256=zV8LNB5I3mn5KTWsRr5kNd3o8WZuMkMWSN7nEq7ktNM,156
|
|
2
|
+
atoti_jdbc/_infer_driver.py,sha256=07ECx-rJAO48X5gf25O8mBOiXDr9BgUMC3InFCf_X9g,817
|
|
3
|
+
atoti_jdbc/_jdbc_ping_discovery_protocol.py,sha256=qtq17sww_PgaCx4W_xUCWJ-kFMGq1mPfImDU3FKpB0k,1611
|
|
4
|
+
atoti_jdbc/driver.py,sha256=9gdxrKKkHUB55npyqp8om7Gp9xgChbfoj8pyFaBTIwQ,1291
|
|
5
|
+
atoti_jdbc/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
atoti_jdbc/user_content_storage_config.py,sha256=3SqSmxeTPvKW9b-Zc2UPJYInC-_0vOxhkfq8pXbsHvw,2193
|
|
7
|
+
atoti_client_jdbc-0.9.0.dist-info/METADATA,sha256=FnDk8DpBMFFA7KbOh1aFR2IPD9lUGbMrUr_n2IRDHPU,945
|
|
8
|
+
atoti_client_jdbc-0.9.0.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
|
9
|
+
atoti_client_jdbc-0.9.0.dist-info/RECORD,,
|
atoti_jdbc/__init__.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from collections.abc import Mapping
|
|
3
|
+
|
|
4
|
+
from .driver import (
|
|
5
|
+
H2_DRIVER,
|
|
6
|
+
IBM_DB2_DRIVER,
|
|
7
|
+
MARIADB_DRIVER,
|
|
8
|
+
MSSQL_DRIVER,
|
|
9
|
+
MYSQL_DRIVER,
|
|
10
|
+
ORACLE_DRIVER,
|
|
11
|
+
POSTGRESQL_DRIVER,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
_DRIVER_FROM_PATH: Mapping[str, str] = {
|
|
15
|
+
"db2": IBM_DB2_DRIVER,
|
|
16
|
+
"h2": H2_DRIVER,
|
|
17
|
+
"mariadb": MARIADB_DRIVER,
|
|
18
|
+
"mysql": MYSQL_DRIVER,
|
|
19
|
+
"oracle": ORACLE_DRIVER,
|
|
20
|
+
"postgresql": POSTGRESQL_DRIVER,
|
|
21
|
+
"sqlserver": MSSQL_DRIVER,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def infer_driver(url: str, /) -> str:
|
|
26
|
+
match = re.match(r"jdbc:(?P<driver_path>[^:]+):", url)
|
|
27
|
+
driver_path = match.group("driver_path") if match else None
|
|
28
|
+
driver = _DRIVER_FROM_PATH.get(driver_path) if driver_path else None
|
|
29
|
+
|
|
30
|
+
if not driver:
|
|
31
|
+
raise ValueError(
|
|
32
|
+
f"Cannot infer driver from URL: `{url}`.",
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
return driver
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
from dataclasses import KW_ONLY
|
|
2
|
+
from typing import final
|
|
3
|
+
|
|
4
|
+
from atoti._pydantic import PYDANTIC_CONFIG as _PYDANTIC_CONFIG
|
|
5
|
+
from atoti.experimental._distributed import DiscoveryProtocol
|
|
6
|
+
from pydantic.dataclasses import dataclass
|
|
7
|
+
from typing_extensions import override
|
|
8
|
+
|
|
9
|
+
from ._infer_driver import infer_driver
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@final
|
|
13
|
+
@dataclass(config=_PYDANTIC_CONFIG, frozen=True)
|
|
14
|
+
class JdbcPingDiscoveryProtocol(DiscoveryProtocol):
|
|
15
|
+
connection_url: str
|
|
16
|
+
|
|
17
|
+
_: KW_ONLY
|
|
18
|
+
|
|
19
|
+
connection_username: str
|
|
20
|
+
|
|
21
|
+
connection_password: str
|
|
22
|
+
|
|
23
|
+
connection_driver: str | None = None
|
|
24
|
+
"""The :mod:`~atoti.jdbc_driver` to use.
|
|
25
|
+
|
|
26
|
+
If ``None``, it is inferred from :attr:`connection_url`.
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
delete_single_sql: str | None = None
|
|
30
|
+
|
|
31
|
+
initialize_sql: str | None = None
|
|
32
|
+
|
|
33
|
+
insert_single_sql: str | None = None
|
|
34
|
+
|
|
35
|
+
remove_all_data_on_view_change: bool = True
|
|
36
|
+
""""Defined by the FILE_PING protocol.
|
|
37
|
+
|
|
38
|
+
See http://jgroups.org/manual4/index.html#_removal_of_zombie_files.
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
remove_old_coords_on_view_change: bool = True
|
|
42
|
+
""""Defined by the FILE_PING protocol.
|
|
43
|
+
|
|
44
|
+
See http://jgroups.org/manual4/index.html#_removal_of_zombie_files.
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
select_all_pingdata_sql: str | None = None
|
|
48
|
+
|
|
49
|
+
write_data_on_find: bool = True
|
|
50
|
+
""""Defined by the FILE_PING protocol.
|
|
51
|
+
|
|
52
|
+
See http://jgroups.org/manual4/index.html#_removal_of_zombie_files.
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
def __post_init__(self) -> None:
|
|
56
|
+
if self.connection_driver is None:
|
|
57
|
+
self.__dict__["connection_driver"] = infer_driver(self.connection_url)
|
|
58
|
+
|
|
59
|
+
@property
|
|
60
|
+
@override
|
|
61
|
+
def _protocol_name(self) -> str:
|
|
62
|
+
return "JDBC_PING"
|
atoti_jdbc/driver.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"""Constants for the provided JDBC drivers.
|
|
2
|
+
|
|
3
|
+
To use another JDBC driver, add its JAR to the :attr:`~atoti.SessionConfig.extra_jars`.
|
|
4
|
+
|
|
5
|
+
Example:
|
|
6
|
+
Storing user content in Google BigQuery:
|
|
7
|
+
|
|
8
|
+
>>> import glob
|
|
9
|
+
>>> from atoti_jdbc import UserContentStorageConfig
|
|
10
|
+
>>> user_content_storage_config = UserContentStorageConfig(
|
|
11
|
+
... "jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443;ProjectId=PROJECT_ID;OAuthType=0;OAuthServiceAcctEmail=EMAIL_OF_SERVICEACCOUNT;OAuthPvtKeyPath=path/to/json/keys;",
|
|
12
|
+
... driver="com.simba.googlebigquery.jdbc42.Driver",
|
|
13
|
+
... )
|
|
14
|
+
>>> session_config = tt.SessionConfig(
|
|
15
|
+
... extra_jars=glob.glob("./odbc_jdbc_drivers/*.jar"),
|
|
16
|
+
... user_content_storage=user_content_storage_config,
|
|
17
|
+
... )
|
|
18
|
+
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
from atoti._jdbc import H2_DRIVER as _H2_DRIVER
|
|
22
|
+
|
|
23
|
+
H2_DRIVER = _H2_DRIVER
|
|
24
|
+
"""H2 driver."""
|
|
25
|
+
|
|
26
|
+
IBM_DB2_DRIVER = "com.ibm.db2.jcc.DB2Driver"
|
|
27
|
+
"""IBM Db2 driver."""
|
|
28
|
+
|
|
29
|
+
MARIADB_DRIVER = "org.mariadb.jdbc.Driver"
|
|
30
|
+
"""MariaDB driver."""
|
|
31
|
+
|
|
32
|
+
MSSQL_DRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver"
|
|
33
|
+
"""Microsoft SQL Server driver."""
|
|
34
|
+
|
|
35
|
+
MYSQL_DRIVER = "com.mysql.cj.jdbc.Driver"
|
|
36
|
+
"""MySQL driver."""
|
|
37
|
+
|
|
38
|
+
ORACLE_DRIVER = "oracle.jdbc.OracleDriver"
|
|
39
|
+
"""Oracle driver."""
|
|
40
|
+
|
|
41
|
+
POSTGRESQL_DRIVER = "org.postgresql.Driver"
|
|
42
|
+
"""PostgreSQL driver."""
|
atoti_jdbc/py.typed
ADDED
|
File without changes
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
from dataclasses import KW_ONLY
|
|
2
|
+
from typing import Annotated, final
|
|
3
|
+
|
|
4
|
+
from atoti._collections import FrozenMapping, frozendict
|
|
5
|
+
from atoti._jdbc import normalize_jdbc_url
|
|
6
|
+
from atoti._pydantic import PYDANTIC_CONFIG as _PYDANTIC_CONFIG
|
|
7
|
+
from pydantic import AfterValidator
|
|
8
|
+
from pydantic.dataclasses import dataclass
|
|
9
|
+
|
|
10
|
+
from ._infer_driver import infer_driver
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@final
|
|
14
|
+
@dataclass(config=_PYDANTIC_CONFIG, frozen=True)
|
|
15
|
+
class UserContentStorageConfig:
|
|
16
|
+
"""The config for storing user content in a separate database.
|
|
17
|
+
|
|
18
|
+
Example:
|
|
19
|
+
>>> from atoti_jdbc import UserContentStorageConfig
|
|
20
|
+
>>> config = UserContentStorageConfig(
|
|
21
|
+
... "mysql://localhost:7777/example?user=username&password=passwd"
|
|
22
|
+
... )
|
|
23
|
+
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
url: Annotated[str, AfterValidator(normalize_jdbc_url)]
|
|
27
|
+
"""The JDBC connection string of the database.
|
|
28
|
+
|
|
29
|
+
The ``jdbc`` scheme is optional but the database specific scheme (such as ``h2`` or ``mysql``) is mandatory.
|
|
30
|
+
For instance:
|
|
31
|
+
|
|
32
|
+
* ``"h2:file:/home/user/database/file/path;USER=username;PASSWORD=passwd"``
|
|
33
|
+
* ``"mysql://localhost:7777/example?user=username&password=passwd"``
|
|
34
|
+
* ``"postgresql://postgresql.db.server:5430/example?user=username&password=passwd"``
|
|
35
|
+
|
|
36
|
+
More examples can be found `here <https://www.baeldung.com/java-jdbc-url-format>`__.
|
|
37
|
+
|
|
38
|
+
This defines Hibernate's `URL <https://javadoc.io/static/org.hibernate/hibernate-core/5.6.15.Final/org/hibernate/cfg/AvailableSettings.html#URL>`__ option.
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
_: KW_ONLY
|
|
42
|
+
|
|
43
|
+
driver: str | None = None
|
|
44
|
+
"""The :mod:`~atoti_jdbc.driver` used to load the data.
|
|
45
|
+
|
|
46
|
+
This defines Hibernate's `DRIVER <https://javadoc.io/static/org.hibernate/hibernate-core/5.6.15.Final/org/hibernate/cfg/AvailableSettings.html#DRIVER>`__ option.
|
|
47
|
+
|
|
48
|
+
Inferred from :attr:`url` if ``None``.
|
|
49
|
+
"""
|
|
50
|
+
|
|
51
|
+
hibernate_options: FrozenMapping[str, str] = frozendict()
|
|
52
|
+
"""Extra options to pass to Hibernate.
|
|
53
|
+
|
|
54
|
+
See `AvailableSettings <https://javadoc.io/static/org.hibernate/hibernate-core/5.6.15.Final/org/hibernate/cfg/AvailableSettings.html>`__.
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
def __post_init__(self) -> None:
|
|
58
|
+
if self.driver is None:
|
|
59
|
+
self.__dict__["driver"] = infer_driver(self.url)
|