macrostrat.database 3.3.3__tar.gz → 3.4.1__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.
- {macrostrat_database-3.3.3 → macrostrat_database-3.4.1}/PKG-INFO +3 -3
- {macrostrat_database-3.3.3 → macrostrat_database-3.4.1}/macrostrat/database/__init__.py +9 -7
- {macrostrat_database-3.3.3 → macrostrat_database-3.4.1}/pyproject.toml +3 -3
- {macrostrat_database-3.3.3 → macrostrat_database-3.4.1}/macrostrat/database/mapper/__init__.py +0 -0
- {macrostrat_database-3.3.3 → macrostrat_database-3.4.1}/macrostrat/database/mapper/base.py +0 -0
- {macrostrat_database-3.3.3 → macrostrat_database-3.4.1}/macrostrat/database/mapper/cache.py +0 -0
- {macrostrat_database-3.3.3 → macrostrat_database-3.4.1}/macrostrat/database/mapper/utils.py +0 -0
- {macrostrat_database-3.3.3 → macrostrat_database-3.4.1}/macrostrat/database/postgresql.py +0 -0
- {macrostrat_database-3.3.3 → macrostrat_database-3.4.1}/macrostrat/database/transfer/__init__.py +0 -0
- {macrostrat_database-3.3.3 → macrostrat_database-3.4.1}/macrostrat/database/transfer/dump_database.py +0 -0
- {macrostrat_database-3.3.3 → macrostrat_database-3.4.1}/macrostrat/database/transfer/move_tables.py +0 -0
- {macrostrat_database-3.3.3 → macrostrat_database-3.4.1}/macrostrat/database/transfer/restore_database.py +0 -0
- {macrostrat_database-3.3.3 → macrostrat_database-3.4.1}/macrostrat/database/transfer/utils.py +0 -0
- {macrostrat_database-3.3.3 → macrostrat_database-3.4.1}/macrostrat/database/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: macrostrat.database
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.4.1
|
|
4
4
|
Summary: A SQLAlchemy-based database toolkit.
|
|
5
5
|
Author: Daven Quinn
|
|
6
6
|
Author-email: dev@davenquinn.com
|
|
@@ -11,7 +11,7 @@ Classifier: Programming Language :: Python :: 3.9
|
|
|
11
11
|
Classifier: Programming Language :: Python :: 3.10
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.11
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
-
Requires-Dist: GeoAlchemy2 (>=0.
|
|
14
|
+
Requires-Dist: GeoAlchemy2 (>=0.15.2,<0.16.0)
|
|
15
15
|
Requires-Dist: SQLAlchemy (>=2.0.18,<3.0.0)
|
|
16
16
|
Requires-Dist: SQLAlchemy-Utils (>=0.41.1,<0.42.0)
|
|
17
17
|
Requires-Dist: aiofiles (>=23.2.1,<24.0.0)
|
|
@@ -19,4 +19,4 @@ Requires-Dist: click (>=8.1.3,<9.0.0)
|
|
|
19
19
|
Requires-Dist: macrostrat.utils (>=1.0.0,<2.0.0)
|
|
20
20
|
Requires-Dist: psycopg2-binary (>=2.9.6,<3.0.0)
|
|
21
21
|
Requires-Dist: rich (>=13.7.1,<14.0.0)
|
|
22
|
-
Requires-Dist: sqlparse (>=0.
|
|
22
|
+
Requires-Dist: sqlparse (>=0.5.1,<0.6.0)
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import warnings
|
|
2
2
|
from contextlib import contextmanager
|
|
3
|
-
from enum import Enum
|
|
4
3
|
from pathlib import Path
|
|
5
4
|
from typing import Optional, Union
|
|
6
5
|
|
|
7
6
|
from psycopg2.errors import InvalidSavepointSpecification
|
|
8
7
|
from psycopg2.sql import Identifier
|
|
9
|
-
from sqlalchemy import URL, MetaData, create_engine, inspect,
|
|
8
|
+
from sqlalchemy import URL, MetaData, create_engine, inspect, Engine
|
|
10
9
|
from sqlalchemy.exc import IntegrityError, InternalError
|
|
11
10
|
from sqlalchemy.ext.compiler import compiles
|
|
12
11
|
from sqlalchemy.orm import Session, scoped_session, sessionmaker
|
|
13
12
|
from sqlalchemy.sql.expression import Insert
|
|
14
13
|
|
|
15
14
|
from macrostrat.utils import get_logger
|
|
16
|
-
|
|
17
15
|
from .mapper import DatabaseMapper
|
|
18
16
|
from .postgresql import on_conflict, prefix_inserts # noqa
|
|
19
17
|
from .utils import ( # noqa
|
|
@@ -41,14 +39,14 @@ class Database(object):
|
|
|
41
39
|
|
|
42
40
|
__inspector__ = None
|
|
43
41
|
|
|
44
|
-
def __init__(self, db_conn: Union[str, URL], *, echo_sql=False, **kwargs):
|
|
42
|
+
def __init__(self, db_conn: Union[str, URL, Engine], *, echo_sql=False, **kwargs):
|
|
45
43
|
"""
|
|
46
44
|
Wrapper for interacting with a database using SQLAlchemy.
|
|
47
45
|
Optimized for use with PostgreSQL, but usable with SQLite
|
|
48
46
|
as well.
|
|
49
47
|
|
|
50
48
|
Args:
|
|
51
|
-
db_conn (str): Connection string for the database.
|
|
49
|
+
db_conn (str | URL | Engine): Connection string or engine for the database.
|
|
52
50
|
|
|
53
51
|
Keyword Args:
|
|
54
52
|
echo_sql (bool): If True, will echo SQL commands to the
|
|
@@ -61,8 +59,12 @@ class Database(object):
|
|
|
61
59
|
|
|
62
60
|
self.instance_params = kwargs.pop("instance_params", {})
|
|
63
61
|
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
if isinstance(db_conn, Engine):
|
|
63
|
+
log.info(f"Set up database connection with engine {db_conn.url}")
|
|
64
|
+
self.engine = db_conn
|
|
65
|
+
else:
|
|
66
|
+
log.info(f"Setting up database connection with URL '{db_conn}'")
|
|
67
|
+
self.engine = create_engine(db_conn, echo=echo_sql, **kwargs)
|
|
66
68
|
self.metadata = kwargs.get("metadata", metadata)
|
|
67
69
|
|
|
68
70
|
# Scoped session for database
|
|
@@ -3,17 +3,17 @@ authors = ["Daven Quinn <dev@davenquinn.com>"]
|
|
|
3
3
|
description = "A SQLAlchemy-based database toolkit."
|
|
4
4
|
name = "macrostrat.database"
|
|
5
5
|
packages = [{ include = "macrostrat" }]
|
|
6
|
-
version = "3.
|
|
6
|
+
version = "3.4.1"
|
|
7
7
|
|
|
8
8
|
[tool.poetry.dependencies]
|
|
9
|
-
GeoAlchemy2 = "^0.
|
|
9
|
+
GeoAlchemy2 = "^0.15.2"
|
|
10
10
|
SQLAlchemy = "^2.0.18"
|
|
11
11
|
SQLAlchemy-Utils = "^0.41.1"
|
|
12
12
|
click = "^8.1.3"
|
|
13
13
|
"macrostrat.utils" = "^1.0.0"
|
|
14
14
|
psycopg2-binary = "^2.9.6"
|
|
15
15
|
python = "^3.8"
|
|
16
|
-
sqlparse = "^0.
|
|
16
|
+
sqlparse = "^0.5.1"
|
|
17
17
|
aiofiles = "^23.2.1"
|
|
18
18
|
rich = "^13.7.1"
|
|
19
19
|
|
{macrostrat_database-3.3.3 → macrostrat_database-3.4.1}/macrostrat/database/mapper/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{macrostrat_database-3.3.3 → macrostrat_database-3.4.1}/macrostrat/database/transfer/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{macrostrat_database-3.3.3 → macrostrat_database-3.4.1}/macrostrat/database/transfer/move_tables.py
RENAMED
|
File without changes
|
|
File without changes
|
{macrostrat_database-3.3.3 → macrostrat_database-3.4.1}/macrostrat/database/transfer/utils.py
RENAMED
|
File without changes
|
|
File without changes
|