hdx-python-database 1.3.3__py3-none-any.whl → 1.3.5__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.
- hdx/database/__init__.py +3 -1
- hdx/database/_version.py +2 -2
- hdx/database/postgresql.py +1 -1
- hdx/database/views.py +8 -17
- {hdx_python_database-1.3.3.dist-info → hdx_python_database-1.3.5.dist-info}/METADATA +2 -2
- hdx_python_database-1.3.5.dist-info/RECORD +12 -0
- {hdx_python_database-1.3.3.dist-info → hdx_python_database-1.3.5.dist-info}/WHEEL +1 -1
- hdx_python_database-1.3.3.dist-info/RECORD +0 -12
- {hdx_python_database-1.3.3.dist-info → hdx_python_database-1.3.5.dist-info}/licenses/LICENSE +0 -0
hdx/database/__init__.py
CHANGED
|
@@ -258,7 +258,9 @@ class Database:
|
|
|
258
258
|
engine = create_engine(db_uri, poolclass=NullPool, echo=False)
|
|
259
259
|
if reflect:
|
|
260
260
|
Base = automap_base(declarative_base=table_base)
|
|
261
|
-
Base.prepare(
|
|
261
|
+
Base.prepare(
|
|
262
|
+
autoload_with=engine, reflection_options={"views": True}
|
|
263
|
+
)
|
|
262
264
|
table_base = Base
|
|
263
265
|
else:
|
|
264
266
|
table_base.metadata.create_all(engine)
|
hdx/database/_version.py
CHANGED
hdx/database/postgresql.py
CHANGED
|
@@ -87,7 +87,7 @@ def restore_from_pgfile(db_uri: str, pg_restore_file: str) -> str:
|
|
|
87
87
|
except subprocess.CalledProcessError as ex:
|
|
88
88
|
command = " ".join(subprocess_params)
|
|
89
89
|
raise PostgresError(
|
|
90
|
-
f"{command} failed. Return code: {process.returncode}"
|
|
90
|
+
f"{command} failed. Return code: {process.returncode}. Error: {process.stderr}"
|
|
91
91
|
) from ex
|
|
92
92
|
|
|
93
93
|
for line in process.stdout.splitlines():
|
hdx/database/views.py
CHANGED
|
@@ -7,10 +7,8 @@ https://github.com/sqlalchemy/sqlalchemy/wiki/Views#sqlalchemy-14-20-version
|
|
|
7
7
|
"""
|
|
8
8
|
|
|
9
9
|
import sqlalchemy as sa
|
|
10
|
-
from sqlalchemy import MetaData, Selectable, TableClause
|
|
11
10
|
from sqlalchemy.ext import compiler
|
|
12
11
|
from sqlalchemy.schema import DDLElement
|
|
13
|
-
from sqlalchemy.sql import table
|
|
14
12
|
|
|
15
13
|
|
|
16
14
|
class CreateView(DDLElement):
|
|
@@ -45,22 +43,15 @@ def view_doesnt_exist(ddl, target, connection, **kw):
|
|
|
45
43
|
return not view_exists(ddl, target, connection, **kw)
|
|
46
44
|
|
|
47
45
|
|
|
48
|
-
def view(name
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
Returns:
|
|
57
|
-
TableClause: SQLAlchemy View
|
|
58
|
-
"""
|
|
59
|
-
t = table(name)
|
|
60
|
-
|
|
61
|
-
t._columns._populate_separate_keys(
|
|
62
|
-
col._make_proxy(t) for col in selectable.selected_columns
|
|
46
|
+
def view(name, metadata, selectable):
|
|
47
|
+
t = sa.table(
|
|
48
|
+
name,
|
|
49
|
+
*(
|
|
50
|
+
sa.Column(c.name, c.type, primary_key=c.primary_key)
|
|
51
|
+
for c in selectable.selected_columns
|
|
52
|
+
),
|
|
63
53
|
)
|
|
54
|
+
t.primary_key.update(c for c in t.c if c.primary_key)
|
|
64
55
|
|
|
65
56
|
sa.event.listen(
|
|
66
57
|
metadata,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: hdx-python-database
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.5
|
|
4
4
|
Summary: HDX Python database utilities
|
|
5
5
|
Project-URL: Homepage, https://github.com/OCHA-DAP/hdx-python-database
|
|
6
6
|
Author-email: Michael Rans <rans@email.com>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
hdx/database/__init__.py,sha256=KS5VOdLv9P-YDTE_2ZUtVm6QNwezNpXMSd7SvMYU4EM,11655
|
|
2
|
+
hdx/database/_version.py,sha256=FcYWgM5oYgqvidiF8nHnDFf0uLGibSe_Bdaq7MY6S4U,411
|
|
3
|
+
hdx/database/dburi.py,sha256=rw8RuLpU85vxYl5-Zk1SdZRAz-tqre_ot5aEnkjhxAQ,2977
|
|
4
|
+
hdx/database/no_timezone.py,sha256=Lw087G3qOf8H70o8Hq_VvOMZ3ANei-lIA_sUlpFU_Uo,1130
|
|
5
|
+
hdx/database/postgresql.py,sha256=i5s_CJQZagMTuzgmnLakCOnSnvczpgJ26Q1CV6lz2_A,2646
|
|
6
|
+
hdx/database/utils.py,sha256=6lLymWriMFCq8BZgrDt4V5z14GR3PbvG_WXZeBc99Ws,415
|
|
7
|
+
hdx/database/views.py,sha256=U4BN9tbjlr93qKkeNbZNo_PCIwGsng09mQ2xFqh5CH0,1636
|
|
8
|
+
hdx/database/with_timezone.py,sha256=GUUylmTwQHp22yedmCVKpVJzvjWgdS9lg9KeqciNJkY,235
|
|
9
|
+
hdx_python_database-1.3.5.dist-info/METADATA,sha256=7aChW3Z69gXHOYG1fITGuN1dssWgCu7z2_VP4Lx1hao,2691
|
|
10
|
+
hdx_python_database-1.3.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
11
|
+
hdx_python_database-1.3.5.dist-info/licenses/LICENSE,sha256=wc-4GpMn-ODs-U_bTe1YCiPVgvcjzrpYOx2wPuyAeII,1079
|
|
12
|
+
hdx_python_database-1.3.5.dist-info/RECORD,,
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
hdx/database/__init__.py,sha256=EYVc16LZCPFULDd9cHHt0S1MKREzE94DtF_MkBhFVng,11589
|
|
2
|
-
hdx/database/_version.py,sha256=VriGPi1kVXIBM0YGAuhpE803XR-FNq1JvTW1Kz2us08,411
|
|
3
|
-
hdx/database/dburi.py,sha256=rw8RuLpU85vxYl5-Zk1SdZRAz-tqre_ot5aEnkjhxAQ,2977
|
|
4
|
-
hdx/database/no_timezone.py,sha256=Lw087G3qOf8H70o8Hq_VvOMZ3ANei-lIA_sUlpFU_Uo,1130
|
|
5
|
-
hdx/database/postgresql.py,sha256=BrEuRnuR2dt3HwJ-o_IzGFs8eT3iXKzDqMSNKPyQ18Y,2621
|
|
6
|
-
hdx/database/utils.py,sha256=6lLymWriMFCq8BZgrDt4V5z14GR3PbvG_WXZeBc99Ws,415
|
|
7
|
-
hdx/database/views.py,sha256=R_1Ni0U2CL3IlydxcB1vyZp7QoDZim6g-807jQIaWQU,1950
|
|
8
|
-
hdx/database/with_timezone.py,sha256=GUUylmTwQHp22yedmCVKpVJzvjWgdS9lg9KeqciNJkY,235
|
|
9
|
-
hdx_python_database-1.3.3.dist-info/METADATA,sha256=zpM5pfKKaDgOwzDxEfcjctN1me8xY0cKYi88klSrxAM,2691
|
|
10
|
-
hdx_python_database-1.3.3.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
|
11
|
-
hdx_python_database-1.3.3.dist-info/licenses/LICENSE,sha256=wc-4GpMn-ODs-U_bTe1YCiPVgvcjzrpYOx2wPuyAeII,1079
|
|
12
|
-
hdx_python_database-1.3.3.dist-info/RECORD,,
|
{hdx_python_database-1.3.3.dist-info → hdx_python_database-1.3.5.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|