sqlalchemy-multiple-db 1.8.0__tar.gz → 2.1.0__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.
- sqlalchemy-multiple-db-2.1.0/PKG-INFO +81 -0
- {sqlalchemy-multiple-db-1.8.0 → sqlalchemy-multiple-db-2.1.0}/README.md +2 -0
- {sqlalchemy-multiple-db-1.8.0 → sqlalchemy-multiple-db-2.1.0}/setup.py +5 -1
- sqlalchemy-multiple-db-2.1.0/sqlalchemy_multiple_db/__init__.py +3 -0
- {sqlalchemy-multiple-db-1.8.0 → sqlalchemy-multiple-db-2.1.0}/sqlalchemy_multiple_db/helper.py +32 -28
- {sqlalchemy-multiple-db-1.8.0 → sqlalchemy-multiple-db-2.1.0}/sqlalchemy_multiple_db/version.py +1 -1
- sqlalchemy-multiple-db-2.1.0/sqlalchemy_multiple_db.egg-info/PKG-INFO +81 -0
- sqlalchemy-multiple-db-2.1.0/sqlalchemy_multiple_db.egg-info/requires.txt +1 -0
- sqlalchemy-multiple-db-1.8.0/PKG-INFO +0 -74
- sqlalchemy-multiple-db-1.8.0/sqlalchemy_multiple_db/__init__.py +0 -3
- sqlalchemy-multiple-db-1.8.0/sqlalchemy_multiple_db.egg-info/PKG-INFO +0 -74
- sqlalchemy-multiple-db-1.8.0/sqlalchemy_multiple_db.egg-info/requires.txt +0 -1
- {sqlalchemy-multiple-db-1.8.0 → sqlalchemy-multiple-db-2.1.0}/LICENSE +0 -0
- {sqlalchemy-multiple-db-1.8.0 → sqlalchemy-multiple-db-2.1.0}/MANIFEST.in +0 -0
- {sqlalchemy-multiple-db-1.8.0 → sqlalchemy-multiple-db-2.1.0}/pyproject.toml +0 -0
- {sqlalchemy-multiple-db-1.8.0 → sqlalchemy-multiple-db-2.1.0}/setup.cfg +0 -0
- {sqlalchemy-multiple-db-1.8.0 → sqlalchemy-multiple-db-2.1.0}/sqlalchemy_multiple_db.egg-info/SOURCES.txt +0 -0
- {sqlalchemy-multiple-db-1.8.0 → sqlalchemy-multiple-db-2.1.0}/sqlalchemy_multiple_db.egg-info/dependency_links.txt +0 -0
- {sqlalchemy-multiple-db-1.8.0 → sqlalchemy-multiple-db-2.1.0}/sqlalchemy_multiple_db.egg-info/not-zip-safe +0 -0
- {sqlalchemy-multiple-db-1.8.0 → sqlalchemy-multiple-db-2.1.0}/sqlalchemy_multiple_db.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: sqlalchemy-multiple-db
|
|
3
|
+
Version: 2.1.0
|
|
4
|
+
Summary: Helper for easily connect to multiple databases.
|
|
5
|
+
Home-page: https://github.com/bigbag/sqlalchemy-multiple-db
|
|
6
|
+
Download-URL: https://pypi.python.org/pypi/sqlalchemy-multiple-db
|
|
7
|
+
Author: Pavel Liashkov
|
|
8
|
+
Author-email: pavel.liashkov@protonmail.com
|
|
9
|
+
Maintainer: Pavel Liashkov
|
|
10
|
+
Maintainer-email: pavel.liashkov@protonmail.com
|
|
11
|
+
License: Apache License, Version 2.0
|
|
12
|
+
Platform: POSIX
|
|
13
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
14
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Operating System :: POSIX
|
|
23
|
+
Classifier: Topic :: Software Development
|
|
24
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
25
|
+
Classifier: Environment :: Console
|
|
26
|
+
Classifier: Intended Audience :: Developers
|
|
27
|
+
Requires-Python: >=3.7
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
License-File: LICENSE
|
|
30
|
+
|
|
31
|
+
# sqlalchemy-multiple-db
|
|
32
|
+
|
|
33
|
+
[](https://github.com/bigbag/sqlalchemy-multiple-db/actions?query=workflow%3ACI)
|
|
34
|
+
[](https://codecov.io/gh/bigbag/sqlalchemy-multiple-db)
|
|
35
|
+
[](https://pypi.python.org/pypi/sqlalchemy-multiple-db)
|
|
36
|
+
[](https://pypistats.org/packages/sqlalchemy-multiple-db)
|
|
37
|
+
[](https://github.com/bigbag/sqlalchemy-multiple-db)
|
|
38
|
+
[](https://github.com/bigbag/sqlalchemy-multiple-db/blob/master/LICENSE)
|
|
39
|
+
|
|
40
|
+
**sqlalchemy-multiple-db** helper for easily connect to multiple databases.
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
* [Project Changelog](CHANGELOG.md)
|
|
44
|
+
|
|
45
|
+
## Installation
|
|
46
|
+
|
|
47
|
+
sqlalchemy-multiple-db is available on PyPI.
|
|
48
|
+
Use pip to install:
|
|
49
|
+
|
|
50
|
+
$ pip install sqlalchemy-multiple-db
|
|
51
|
+
|
|
52
|
+
## Basic Usage
|
|
53
|
+
```py
|
|
54
|
+
from sqlalchemy_multiple_db import DBConfig, db
|
|
55
|
+
|
|
56
|
+
db.setup({"test1": DBConfig(dsn="sqlite://"), "test2": DBConfig(dsn="sqlite://")})
|
|
57
|
+
|
|
58
|
+
with db.session_scope("test1") as session:
|
|
59
|
+
assert session.execute("select 1;")
|
|
60
|
+
|
|
61
|
+
with db.session_scope("test2") as session:
|
|
62
|
+
assert session.execute("select 1;")
|
|
63
|
+
|
|
64
|
+
db.shutdown()
|
|
65
|
+
|
|
66
|
+
db.setup(DBConfig(dsn="sqlite://"))
|
|
67
|
+
|
|
68
|
+
with db.session_scope() as session:
|
|
69
|
+
assert session.execute("select 1;")
|
|
70
|
+
|
|
71
|
+
db.shutdown()
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## License
|
|
76
|
+
|
|
77
|
+
sqlalchemy-multiple-db is developed and distributed under the Apache 2.0 license.
|
|
78
|
+
|
|
79
|
+
## Reporting a Security Vulnerability
|
|
80
|
+
|
|
81
|
+
See our [security policy](https://github.com/bigbag/sqlalchemy-multiple-db/security/policy).
|
|
@@ -18,6 +18,10 @@ CLASSIFIERS = [
|
|
|
18
18
|
"Programming Language :: Python :: 3.7",
|
|
19
19
|
"Programming Language :: Python :: 3.8",
|
|
20
20
|
"Programming Language :: Python :: 3.9",
|
|
21
|
+
"Programming Language :: Python :: 3.10",
|
|
22
|
+
"Programming Language :: Python :: 3.11",
|
|
23
|
+
"Programming Language :: Python :: 3.12",
|
|
24
|
+
"Programming Language :: Python :: 3.13",
|
|
21
25
|
"Operating System :: POSIX",
|
|
22
26
|
"Topic :: Software Development",
|
|
23
27
|
"Topic :: Software Development :: Libraries",
|
|
@@ -42,7 +46,7 @@ setup(
|
|
|
42
46
|
platforms=["POSIX"],
|
|
43
47
|
classifiers=CLASSIFIERS,
|
|
44
48
|
python_requires=">=3.7",
|
|
45
|
-
install_requires=["SQLAlchemy>=1.4,<1
|
|
49
|
+
install_requires=["SQLAlchemy>=1.4,<2.1"],
|
|
46
50
|
packages=find_packages(),
|
|
47
51
|
include_package_data=True,
|
|
48
52
|
zip_safe=False,
|
{sqlalchemy-multiple-db-1.8.0 → sqlalchemy-multiple-db-2.1.0}/sqlalchemy_multiple_db/helper.py
RENAMED
|
@@ -2,10 +2,12 @@ import logging
|
|
|
2
2
|
from contextlib import contextmanager
|
|
3
3
|
from dataclasses import dataclass, field
|
|
4
4
|
from json import dumps, loads
|
|
5
|
-
from typing import Any, Dict,
|
|
5
|
+
from typing import Any, Dict, Generator, Tuple, Union
|
|
6
6
|
|
|
7
7
|
from sqlalchemy import create_engine
|
|
8
|
+
from sqlalchemy.exc import SQLAlchemyError
|
|
8
9
|
from sqlalchemy.orm import Session, scoped_session, sessionmaker
|
|
10
|
+
from sqlalchemy.sql import text
|
|
9
11
|
|
|
10
12
|
logger = logging.getLogger(__name__)
|
|
11
13
|
|
|
@@ -24,22 +26,17 @@ DEFAULT_ENGINE_OPTIONS = {
|
|
|
24
26
|
@dataclass
|
|
25
27
|
class DBConfig:
|
|
26
28
|
dsn: str
|
|
27
|
-
session_options:
|
|
28
|
-
engine_options:
|
|
29
|
+
session_options: Dict[str, Any] = field(default_factory=dict)
|
|
30
|
+
engine_options: Dict[str, Any] = field(default_factory=dict)
|
|
29
31
|
|
|
30
32
|
def __post_init__(self):
|
|
31
|
-
session_options = DEFAULT_SESSION_OPTIONS
|
|
32
|
-
|
|
33
|
-
self.session_options = session_options
|
|
34
|
-
|
|
35
|
-
engine_options = DEFAULT_ENGINE_OPTIONS
|
|
36
|
-
engine_options.update(self.engine_options or {})
|
|
37
|
-
self.engine_options = engine_options
|
|
33
|
+
self.session_options = {**DEFAULT_SESSION_OPTIONS, **self.session_options}
|
|
34
|
+
self.engine_options = {**DEFAULT_ENGINE_OPTIONS, **self.engine_options}
|
|
38
35
|
|
|
39
36
|
|
|
40
37
|
@dataclass
|
|
41
38
|
class DBHelper:
|
|
42
|
-
sessions: Dict[str,
|
|
39
|
+
sessions: Dict[str, scoped_session] = field(init=False, repr=False)
|
|
43
40
|
config: Dict[str, DBConfig] = field(init=False, repr=False)
|
|
44
41
|
|
|
45
42
|
def __getattribute__(self, db_name):
|
|
@@ -50,13 +47,14 @@ class DBHelper:
|
|
|
50
47
|
print(f"DB: You need to call setup() for getting attribute {db_name}")
|
|
51
48
|
raise exc
|
|
52
49
|
|
|
53
|
-
def create_scoped_session(self, config: DBConfig) ->
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
50
|
+
def create_scoped_session(self, config: DBConfig) -> scoped_session:
|
|
51
|
+
engine_options = config.engine_options or {}
|
|
52
|
+
session_options = config.session_options or {}
|
|
53
|
+
|
|
54
|
+
session = scoped_session(
|
|
55
|
+
sessionmaker(bind=create_engine(config.dsn, **engine_options), **session_options)
|
|
58
56
|
)
|
|
59
|
-
return session
|
|
57
|
+
return session # type: ignore
|
|
60
58
|
|
|
61
59
|
def setup(self, config: Union[DBConfig, Dict[str, DBConfig]]):
|
|
62
60
|
if isinstance(config, DBConfig):
|
|
@@ -68,32 +66,38 @@ class DBHelper:
|
|
|
68
66
|
for db_name, cfg in config.items():
|
|
69
67
|
self.sessions[db_name] = self.create_scoped_session(cfg)
|
|
70
68
|
|
|
71
|
-
def shutdown(self):
|
|
69
|
+
def shutdown(self) -> None:
|
|
72
70
|
for session in self.sessions.values():
|
|
73
71
|
session.remove()
|
|
72
|
+
self.sessions.clear()
|
|
74
73
|
|
|
75
74
|
@contextmanager
|
|
76
|
-
def session_scope(self, db_name: str = DEFAULT_DB_NAME):
|
|
77
|
-
session =
|
|
75
|
+
def session_scope(self, db_name: str = DEFAULT_DB_NAME) -> Generator[Session, None, None]:
|
|
76
|
+
session = self.sessions.get(db_name)
|
|
77
|
+
if not session:
|
|
78
|
+
raise ValueError(f"No session found for database: {db_name}")
|
|
78
79
|
try:
|
|
79
|
-
yield session
|
|
80
|
+
yield session()
|
|
81
|
+
session.commit()
|
|
82
|
+
except Exception:
|
|
83
|
+
session.rollback()
|
|
84
|
+
raise
|
|
80
85
|
finally:
|
|
81
|
-
session.
|
|
86
|
+
session.remove()
|
|
82
87
|
|
|
83
|
-
def get_status_info(self) -> Tuple[Dict[str,
|
|
88
|
+
def get_status_info(self) -> Tuple[Dict[str, Dict[str, str]], bool]:
|
|
84
89
|
full_status = True
|
|
85
90
|
full_status_info = {}
|
|
86
|
-
|
|
87
91
|
for db_name, session in self.sessions.items():
|
|
88
92
|
status = True
|
|
89
93
|
try:
|
|
90
|
-
session.execute("
|
|
91
|
-
except
|
|
94
|
+
session.execute(text("SELECT 1"))
|
|
95
|
+
except SQLAlchemyError as e:
|
|
96
|
+
logger.exception(f"Database {db_name} connection failed: {e}")
|
|
92
97
|
status &= False
|
|
93
98
|
full_status &= False
|
|
94
|
-
logger.exception(e)
|
|
95
99
|
finally:
|
|
96
|
-
session.
|
|
100
|
+
session.remove()
|
|
97
101
|
|
|
98
102
|
full_status_info[db_name] = {"status": "OK"} if status else {"status": "FAILED"}
|
|
99
103
|
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: sqlalchemy-multiple-db
|
|
3
|
+
Version: 2.1.0
|
|
4
|
+
Summary: Helper for easily connect to multiple databases.
|
|
5
|
+
Home-page: https://github.com/bigbag/sqlalchemy-multiple-db
|
|
6
|
+
Download-URL: https://pypi.python.org/pypi/sqlalchemy-multiple-db
|
|
7
|
+
Author: Pavel Liashkov
|
|
8
|
+
Author-email: pavel.liashkov@protonmail.com
|
|
9
|
+
Maintainer: Pavel Liashkov
|
|
10
|
+
Maintainer-email: pavel.liashkov@protonmail.com
|
|
11
|
+
License: Apache License, Version 2.0
|
|
12
|
+
Platform: POSIX
|
|
13
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
14
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Operating System :: POSIX
|
|
23
|
+
Classifier: Topic :: Software Development
|
|
24
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
25
|
+
Classifier: Environment :: Console
|
|
26
|
+
Classifier: Intended Audience :: Developers
|
|
27
|
+
Requires-Python: >=3.7
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
License-File: LICENSE
|
|
30
|
+
|
|
31
|
+
# sqlalchemy-multiple-db
|
|
32
|
+
|
|
33
|
+
[](https://github.com/bigbag/sqlalchemy-multiple-db/actions?query=workflow%3ACI)
|
|
34
|
+
[](https://codecov.io/gh/bigbag/sqlalchemy-multiple-db)
|
|
35
|
+
[](https://pypi.python.org/pypi/sqlalchemy-multiple-db)
|
|
36
|
+
[](https://pypistats.org/packages/sqlalchemy-multiple-db)
|
|
37
|
+
[](https://github.com/bigbag/sqlalchemy-multiple-db)
|
|
38
|
+
[](https://github.com/bigbag/sqlalchemy-multiple-db/blob/master/LICENSE)
|
|
39
|
+
|
|
40
|
+
**sqlalchemy-multiple-db** helper for easily connect to multiple databases.
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
* [Project Changelog](CHANGELOG.md)
|
|
44
|
+
|
|
45
|
+
## Installation
|
|
46
|
+
|
|
47
|
+
sqlalchemy-multiple-db is available on PyPI.
|
|
48
|
+
Use pip to install:
|
|
49
|
+
|
|
50
|
+
$ pip install sqlalchemy-multiple-db
|
|
51
|
+
|
|
52
|
+
## Basic Usage
|
|
53
|
+
```py
|
|
54
|
+
from sqlalchemy_multiple_db import DBConfig, db
|
|
55
|
+
|
|
56
|
+
db.setup({"test1": DBConfig(dsn="sqlite://"), "test2": DBConfig(dsn="sqlite://")})
|
|
57
|
+
|
|
58
|
+
with db.session_scope("test1") as session:
|
|
59
|
+
assert session.execute("select 1;")
|
|
60
|
+
|
|
61
|
+
with db.session_scope("test2") as session:
|
|
62
|
+
assert session.execute("select 1;")
|
|
63
|
+
|
|
64
|
+
db.shutdown()
|
|
65
|
+
|
|
66
|
+
db.setup(DBConfig(dsn="sqlite://"))
|
|
67
|
+
|
|
68
|
+
with db.session_scope() as session:
|
|
69
|
+
assert session.execute("select 1;")
|
|
70
|
+
|
|
71
|
+
db.shutdown()
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## License
|
|
76
|
+
|
|
77
|
+
sqlalchemy-multiple-db is developed and distributed under the Apache 2.0 license.
|
|
78
|
+
|
|
79
|
+
## Reporting a Security Vulnerability
|
|
80
|
+
|
|
81
|
+
See our [security policy](https://github.com/bigbag/sqlalchemy-multiple-db/security/policy).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
SQLAlchemy<2.1,>=1.4
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: sqlalchemy-multiple-db
|
|
3
|
-
Version: 1.8.0
|
|
4
|
-
Summary: Helper for easily connect to multiple databases.
|
|
5
|
-
Home-page: https://github.com/bigbag/sqlalchemy-multiple-db
|
|
6
|
-
Author: Pavel Liashkov
|
|
7
|
-
Author-email: pavel.liashkov@protonmail.com
|
|
8
|
-
Maintainer: Pavel Liashkov
|
|
9
|
-
Maintainer-email: pavel.liashkov@protonmail.com
|
|
10
|
-
License: Apache License, Version 2.0
|
|
11
|
-
Download-URL: https://pypi.python.org/pypi/sqlalchemy-multiple-db
|
|
12
|
-
Description: # sqlalchemy-multiple-db
|
|
13
|
-
|
|
14
|
-
[](https://github.com/bigbag/sqlalchemy-multiple-db/actions?query=workflow%3ACI)
|
|
15
|
-
[](https://codecov.io/gh/bigbag/sqlalchemy-multiple-db)
|
|
16
|
-
[](https://pypi.python.org/pypi/sqlalchemy-multiple-db)
|
|
17
|
-
[](https://pypistats.org/packages/sqlalchemy-multiple-db)
|
|
18
|
-
[](https://github.com/bigbag/sqlalchemy-multiple-db)
|
|
19
|
-
[](https://github.com/bigbag/sqlalchemy-multiple-db/blob/master/LICENSE)
|
|
20
|
-
|
|
21
|
-
**sqlalchemy-multiple-db** helper for easily connect to multiple databases.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
## Installation
|
|
25
|
-
|
|
26
|
-
sqlalchemy-multiple-db is available on PyPI.
|
|
27
|
-
Use pip to install:
|
|
28
|
-
|
|
29
|
-
$ pip install sqlalchemy-multiple-db
|
|
30
|
-
|
|
31
|
-
## Basic Usage
|
|
32
|
-
```py
|
|
33
|
-
from sqlalchemy_multiple_db import DBConfig, db
|
|
34
|
-
|
|
35
|
-
db.setup({"test1": DBConfig(dsn="sqlite://"), "test2": DBConfig(dsn="sqlite://")})
|
|
36
|
-
|
|
37
|
-
with db.session_scope("test1") as session:
|
|
38
|
-
assert session.execute("select 1;")
|
|
39
|
-
|
|
40
|
-
with db.session_scope("test2") as session:
|
|
41
|
-
assert session.execute("select 1;")
|
|
42
|
-
|
|
43
|
-
db.shutdown()
|
|
44
|
-
|
|
45
|
-
db.setup(DBConfig(dsn="sqlite://"))
|
|
46
|
-
|
|
47
|
-
with db.session_scope() as session:
|
|
48
|
-
assert session.execute("select 1;")
|
|
49
|
-
|
|
50
|
-
db.shutdown()
|
|
51
|
-
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
## License
|
|
55
|
-
|
|
56
|
-
sqlalchemy-multiple-db is developed and distributed under the Apache 2.0 license.
|
|
57
|
-
|
|
58
|
-
## Reporting a Security Vulnerability
|
|
59
|
-
|
|
60
|
-
See our [security policy](https://github.com/bigbag/sqlalchemy-multiple-db/security/policy).
|
|
61
|
-
|
|
62
|
-
Platform: POSIX
|
|
63
|
-
Classifier: Development Status :: 5 - Production/Stable
|
|
64
|
-
Classifier: Programming Language :: Python :: 3 :: Only
|
|
65
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
66
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
67
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
68
|
-
Classifier: Operating System :: POSIX
|
|
69
|
-
Classifier: Topic :: Software Development
|
|
70
|
-
Classifier: Topic :: Software Development :: Libraries
|
|
71
|
-
Classifier: Environment :: Console
|
|
72
|
-
Classifier: Intended Audience :: Developers
|
|
73
|
-
Requires-Python: >=3.7
|
|
74
|
-
Description-Content-Type: text/markdown
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: sqlalchemy-multiple-db
|
|
3
|
-
Version: 1.8.0
|
|
4
|
-
Summary: Helper for easily connect to multiple databases.
|
|
5
|
-
Home-page: https://github.com/bigbag/sqlalchemy-multiple-db
|
|
6
|
-
Author: Pavel Liashkov
|
|
7
|
-
Author-email: pavel.liashkov@protonmail.com
|
|
8
|
-
Maintainer: Pavel Liashkov
|
|
9
|
-
Maintainer-email: pavel.liashkov@protonmail.com
|
|
10
|
-
License: Apache License, Version 2.0
|
|
11
|
-
Download-URL: https://pypi.python.org/pypi/sqlalchemy-multiple-db
|
|
12
|
-
Description: # sqlalchemy-multiple-db
|
|
13
|
-
|
|
14
|
-
[](https://github.com/bigbag/sqlalchemy-multiple-db/actions?query=workflow%3ACI)
|
|
15
|
-
[](https://codecov.io/gh/bigbag/sqlalchemy-multiple-db)
|
|
16
|
-
[](https://pypi.python.org/pypi/sqlalchemy-multiple-db)
|
|
17
|
-
[](https://pypistats.org/packages/sqlalchemy-multiple-db)
|
|
18
|
-
[](https://github.com/bigbag/sqlalchemy-multiple-db)
|
|
19
|
-
[](https://github.com/bigbag/sqlalchemy-multiple-db/blob/master/LICENSE)
|
|
20
|
-
|
|
21
|
-
**sqlalchemy-multiple-db** helper for easily connect to multiple databases.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
## Installation
|
|
25
|
-
|
|
26
|
-
sqlalchemy-multiple-db is available on PyPI.
|
|
27
|
-
Use pip to install:
|
|
28
|
-
|
|
29
|
-
$ pip install sqlalchemy-multiple-db
|
|
30
|
-
|
|
31
|
-
## Basic Usage
|
|
32
|
-
```py
|
|
33
|
-
from sqlalchemy_multiple_db import DBConfig, db
|
|
34
|
-
|
|
35
|
-
db.setup({"test1": DBConfig(dsn="sqlite://"), "test2": DBConfig(dsn="sqlite://")})
|
|
36
|
-
|
|
37
|
-
with db.session_scope("test1") as session:
|
|
38
|
-
assert session.execute("select 1;")
|
|
39
|
-
|
|
40
|
-
with db.session_scope("test2") as session:
|
|
41
|
-
assert session.execute("select 1;")
|
|
42
|
-
|
|
43
|
-
db.shutdown()
|
|
44
|
-
|
|
45
|
-
db.setup(DBConfig(dsn="sqlite://"))
|
|
46
|
-
|
|
47
|
-
with db.session_scope() as session:
|
|
48
|
-
assert session.execute("select 1;")
|
|
49
|
-
|
|
50
|
-
db.shutdown()
|
|
51
|
-
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
## License
|
|
55
|
-
|
|
56
|
-
sqlalchemy-multiple-db is developed and distributed under the Apache 2.0 license.
|
|
57
|
-
|
|
58
|
-
## Reporting a Security Vulnerability
|
|
59
|
-
|
|
60
|
-
See our [security policy](https://github.com/bigbag/sqlalchemy-multiple-db/security/policy).
|
|
61
|
-
|
|
62
|
-
Platform: POSIX
|
|
63
|
-
Classifier: Development Status :: 5 - Production/Stable
|
|
64
|
-
Classifier: Programming Language :: Python :: 3 :: Only
|
|
65
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
66
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
67
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
68
|
-
Classifier: Operating System :: POSIX
|
|
69
|
-
Classifier: Topic :: Software Development
|
|
70
|
-
Classifier: Topic :: Software Development :: Libraries
|
|
71
|
-
Classifier: Environment :: Console
|
|
72
|
-
Classifier: Intended Audience :: Developers
|
|
73
|
-
Requires-Python: >=3.7
|
|
74
|
-
Description-Content-Type: text/markdown
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
SQLAlchemy<1.5,>=1.4
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|