hdx-python-database 1.3.6__tar.gz → 1.3.7__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.
Files changed (36) hide show
  1. hdx_python_database-1.3.6/.config/pre-commit-config.yaml → hdx_python_database-1.3.7/.pre-commit-config.yaml +5 -6
  2. {hdx_python_database-1.3.6 → hdx_python_database-1.3.7}/PKG-INFO +4 -2
  3. {hdx_python_database-1.3.6 → hdx_python_database-1.3.7}/documentation/mkdocs.yaml +3 -1
  4. hdx_python_database-1.3.7/hatch.toml +34 -0
  5. {hdx_python_database-1.3.6 → hdx_python_database-1.3.7}/pyproject.toml +2 -48
  6. {hdx_python_database-1.3.6/.config → hdx_python_database-1.3.7}/pytest.ini +1 -1
  7. {hdx_python_database-1.3.6 → hdx_python_database-1.3.7}/requirements.txt +35 -42
  8. {hdx_python_database-1.3.6/.config → hdx_python_database-1.3.7}/ruff.toml +0 -1
  9. {hdx_python_database-1.3.6 → hdx_python_database-1.3.7}/src/hdx/database/_version.py +2 -2
  10. {hdx_python_database-1.3.6 → hdx_python_database-1.3.7}/src/hdx/database/database.py +24 -6
  11. {hdx_python_database-1.3.6 → hdx_python_database-1.3.7}/src/hdx/database/postgresql.py +13 -2
  12. {hdx_python_database-1.3.6 → hdx_python_database-1.3.7}/src/hdx/database/utils.py +1 -3
  13. {hdx_python_database-1.3.6 → hdx_python_database-1.3.7}/tests/hdx/database/test_database.py +1 -3
  14. {hdx_python_database-1.3.6 → hdx_python_database-1.3.7}/tests/hdx/database/test_dburi.py +4 -12
  15. hdx_python_database-1.3.6/tests/hdx/database/test_recreate.py → hdx_python_database-1.3.7/tests/hdx/database/test_drop_recreate.py +7 -0
  16. {hdx_python_database-1.3.6 → hdx_python_database-1.3.7}/tests/hdx/database/test_ssh.py +1 -3
  17. /hdx_python_database-1.3.6/.config/coveragerc → /hdx_python_database-1.3.7/.coveragerc +0 -0
  18. {hdx_python_database-1.3.6 → hdx_python_database-1.3.7}/.github/workflows/publish.yaml +0 -0
  19. {hdx_python_database-1.3.6 → hdx_python_database-1.3.7}/.github/workflows/run-python-tests.yaml +0 -0
  20. {hdx_python_database-1.3.6 → hdx_python_database-1.3.7}/.gitignore +0 -0
  21. {hdx_python_database-1.3.6 → hdx_python_database-1.3.7}/CONTRIBUTING.md +0 -0
  22. {hdx_python_database-1.3.6 → hdx_python_database-1.3.7}/LICENSE +0 -0
  23. {hdx_python_database-1.3.6 → hdx_python_database-1.3.7}/README.md +0 -0
  24. {hdx_python_database-1.3.6 → hdx_python_database-1.3.7}/documentation/.readthedocs.yaml +0 -0
  25. {hdx_python_database-1.3.6 → hdx_python_database-1.3.7}/documentation/index.md +0 -0
  26. {hdx_python_database-1.3.6 → hdx_python_database-1.3.7}/src/hdx/database/__init__.py +0 -0
  27. {hdx_python_database-1.3.6 → hdx_python_database-1.3.7}/src/hdx/database/dburi.py +0 -0
  28. {hdx_python_database-1.3.6 → hdx_python_database-1.3.7}/src/hdx/database/no_timezone.py +0 -0
  29. {hdx_python_database-1.3.6 → hdx_python_database-1.3.7}/src/hdx/database/views.py +0 -0
  30. {hdx_python_database-1.3.6 → hdx_python_database-1.3.7}/src/hdx/database/with_timezone.py +0 -0
  31. {hdx_python_database-1.3.6 → hdx_python_database-1.3.7}/tests/fixtures/test.db +0 -0
  32. {hdx_python_database-1.3.6 → hdx_python_database-1.3.7}/tests/hdx/database/__init__.py +0 -0
  33. {hdx_python_database-1.3.6 → hdx_python_database-1.3.7}/tests/hdx/database/conftest.py +0 -0
  34. {hdx_python_database-1.3.6 → hdx_python_database-1.3.7}/tests/hdx/database/dbtestdate.py +0 -0
  35. {hdx_python_database-1.3.6 → hdx_python_database-1.3.7}/tests/hdx/database/test_postgresql.py +0 -0
  36. {hdx_python_database-1.3.6 → hdx_python_database-1.3.7}/tests/hdx/database/test_reflect.py +0 -0
@@ -1,5 +1,5 @@
1
1
  default_language_version:
2
- python: python3.12
2
+ python: python3.13
3
3
  repos:
4
4
  - repo: https://github.com/pre-commit/pre-commit-hooks
5
5
  rev: v5.0.0
@@ -8,16 +8,15 @@ repos:
8
8
  - id: end-of-file-fixer
9
9
  - id: check-ast
10
10
  - repo: https://github.com/astral-sh/ruff-pre-commit
11
- rev: v0.9.10
11
+ rev: v0.12.0
12
12
  hooks:
13
13
  # Run the linter.
14
- - id: ruff
15
- args: [--config, .config/ruff.toml, --fix]
14
+ - id: ruff-check
15
+ args: [ --fix ]
16
16
  # Run the formatter.
17
17
  - id: ruff-format
18
- args: [--config, .config/ruff.toml]
19
18
  - repo: https://github.com/astral-sh/uv-pre-commit
20
- rev: 0.6.5
19
+ rev: 0.7.14
21
20
  hooks:
22
21
  # Run the pip compile
23
22
  - id: pip-compile
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hdx-python-database
3
- Version: 1.3.6
3
+ Version: 1.3.7
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>
@@ -24,7 +24,7 @@ Classifier: Programming Language :: Python :: 3.10
24
24
  Classifier: Programming Language :: Python :: 3.11
25
25
  Classifier: Programming Language :: Python :: 3.12
26
26
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
27
- Requires-Python: >=3.8
27
+ Requires-Python: >=3.10
28
28
  Requires-Dist: sqlalchemy>=2
29
29
  Provides-Extra: dev
30
30
  Requires-Dist: pre-commit; extra == 'dev'
@@ -35,8 +35,10 @@ Requires-Dist: psycopg[binary]; extra == 'postgresql'
35
35
  Provides-Extra: sshtunnel
36
36
  Requires-Dist: sshtunnel; extra == 'sshtunnel'
37
37
  Provides-Extra: test
38
+ Requires-Dist: psycopg[binary]; extra == 'test'
38
39
  Requires-Dist: pytest; extra == 'test'
39
40
  Requires-Dist: pytest-cov; extra == 'test'
41
+ Requires-Dist: sshtunnel; extra == 'test'
40
42
  Description-Content-Type: text/markdown
41
43
 
42
44
  [![Build Status](https://github.com/OCHA-DAP/hdx-python-database/actions/workflows/run-python-tests.yaml/badge.svg)](https://github.com/OCHA-DAP/hdx-python-database/actions/workflows/run-python-tests.yaml)
@@ -12,5 +12,7 @@ plugins:
12
12
  nav:
13
13
  - Home: index.md
14
14
  - API Documentation:
15
- - Database: $src/hdx.database.*
15
+ - Database:
16
+ - $src/hdx.database.Database
17
+ - $src/hdx.database.DatabaseError
16
18
  - PostgreSQL specific: $src/hdx.database.postgresql.*
@@ -0,0 +1,34 @@
1
+ # Build
2
+
3
+ [build.targets.wheel]
4
+ packages = ["src/hdx"]
5
+
6
+ [build.hooks.vcs]
7
+ version-file = "src/hdx/database/_version.py"
8
+
9
+ # Versioning
10
+
11
+ [version]
12
+ source = "vcs"
13
+
14
+ [version.raw-options]
15
+ local_scheme = "no-local-version"
16
+ version_scheme = "python-simplified-semver"
17
+
18
+ # Tests
19
+
20
+ [envs.hatch-test]
21
+ features = ["test"]
22
+
23
+ [[envs.hatch-test.matrix]]
24
+ python = ["3.13"]
25
+
26
+ [envs.hatch-test.scripts]
27
+ run = """
28
+ pytest --rootdir=. --junitxml=test-results.xml --cov --no-cov-on-fail \
29
+ --cov-report=lcov --cov-report=term-missing
30
+ """
31
+
32
+ [envs.hatch-static-analysis]
33
+ config-path = "none"
34
+ dependencies = ["ruff==0.12.0"]
@@ -31,7 +31,7 @@ classifiers = [
31
31
  "Operating System :: MacOS",
32
32
  "Operating System :: Microsoft :: Windows",
33
33
  ]
34
- requires-python = ">=3.8"
34
+ requires-python = ">=3.10"
35
35
 
36
36
  dependencies = [
37
37
  "sqlalchemy>=2",
@@ -48,52 +48,6 @@ Homepage = "https://github.com/OCHA-DAP/hdx-python-database"
48
48
  [project.optional-dependencies]
49
49
  sshtunnel = ["sshtunnel"]
50
50
  postgresql = ["psycopg[binary]"]
51
- test = ["pytest", "pytest-cov"]
51
+ test = ["sshtunnel", "psycopg[binary]", "pytest", "pytest-cov"]
52
52
  dev = ["pre-commit"]
53
53
  docs = ["mkapi"]
54
-
55
-
56
- #########
57
- # Hatch #
58
- #########
59
-
60
- # Build
61
-
62
- [tool.hatch.build.targets.wheel]
63
- packages = ["src/hdx"]
64
-
65
- [tool.hatch.build.hooks.vcs]
66
- version-file = "src/hdx/database/_version.py"
67
-
68
- # Versioning
69
-
70
- [tool.hatch.version]
71
- source = "vcs"
72
-
73
- [tool.hatch.version.raw-options]
74
- local_scheme = "no-local-version"
75
- version_scheme = "python-simplified-semver"
76
-
77
- # Tests
78
-
79
- [tool.hatch.envs.hatch-test]
80
- features = ["sshtunnel", "postgresql", "test"]
81
-
82
- [[tool.hatch.envs.hatch-test.matrix]]
83
- python = ["3.12"]
84
-
85
- [tool.hatch.envs.hatch-test.scripts]
86
- run = """
87
- pytest -c .config/pytest.ini --rootdir=. --junitxml=test-results.xml \
88
- --cov --cov-config=.config/coveragerc --no-cov-on-fail \
89
- --cov-report=lcov --cov-report=term-missing
90
- """
91
-
92
- [tool.hatch.envs.hatch-static-analysis]
93
- dependencies = ["ruff==0.9.10"]
94
-
95
- [tool.hatch.envs.hatch-static-analysis.scripts]
96
- format-check = ["ruff format --config .config/ruff.toml --check --diff {args:.}",]
97
- format-fix = ["ruff format --config .config/ruff.toml {args:.}",]
98
- lint-check = ["ruff check --config .config/ruff.toml {args:.}",]
99
- lint-fix = ["ruff check --config .config/ruff.toml --fix {args:.}",]
@@ -1,4 +1,4 @@
1
1
  [pytest]
2
- pythonpath = ../src
2
+ pythonpath = src
3
3
  addopts = "--color=yes"
4
4
  log_cli = 1
@@ -1,14 +1,14 @@
1
1
  # This file was autogenerated by uv via the following command:
2
2
  # uv pip compile pyproject.toml --resolver=backtracking --all-extras -o requirements.txt
3
- astdoc==1.1.5
3
+ astdoc==1.3.0
4
4
  # via mkapi
5
5
  babel==2.17.0
6
6
  # via mkdocs-material
7
- backrefs==5.8
7
+ backrefs==5.9
8
8
  # via mkdocs-material
9
9
  bcrypt==4.3.0
10
10
  # via paramiko
11
- certifi==2025.1.31
11
+ certifi==2025.7.14
12
12
  # via requests
13
13
  cffi==1.17.1
14
14
  # via
@@ -16,54 +16,49 @@ cffi==1.17.1
16
16
  # pynacl
17
17
  cfgv==3.4.0
18
18
  # via pre-commit
19
- charset-normalizer==3.4.1
19
+ charset-normalizer==3.4.2
20
20
  # via requests
21
- click==8.1.8
21
+ click==8.2.1
22
22
  # via mkdocs
23
23
  colorama==0.4.6
24
24
  # via mkdocs-material
25
- coverage==7.7.0
25
+ coverage==7.9.2
26
26
  # via pytest-cov
27
- cryptography==44.0.2
27
+ cryptography==45.0.5
28
28
  # via paramiko
29
- distlib==0.3.9
29
+ distlib==0.4.0
30
30
  # via virtualenv
31
31
  filelock==3.18.0
32
32
  # via virtualenv
33
33
  ghp-import==2.1.0
34
34
  # via mkdocs
35
- greenlet==3.1.1
35
+ greenlet==3.2.3
36
36
  # via sqlalchemy
37
- identify==2.6.9
37
+ identify==2.6.12
38
38
  # via pre-commit
39
39
  idna==3.10
40
40
  # via requests
41
- iniconfig==2.0.0
41
+ iniconfig==2.1.0
42
42
  # via pytest
43
43
  jinja2==3.1.6
44
44
  # via
45
45
  # mkapi
46
46
  # mkdocs
47
47
  # mkdocs-material
48
- markdown==3.7
48
+ markdown==3.8.2
49
49
  # via
50
- # astdoc
51
50
  # mkdocs
52
51
  # mkdocs-material
53
52
  # pymdown-extensions
54
- markdown-it-py==3.0.0
55
- # via rich
56
53
  markupsafe==3.0.2
57
54
  # via
58
55
  # jinja2
59
56
  # mkdocs
60
- mdurl==0.1.2
61
- # via markdown-it-py
62
57
  mergedeep==1.3.4
63
58
  # via
64
59
  # mkdocs
65
60
  # mkdocs-get-deps
66
- mkapi==4.1.3
61
+ mkapi==4.4.4
67
62
  # via hdx-python-database (pyproject.toml)
68
63
  mkdocs==1.6.1
69
64
  # via
@@ -71,13 +66,13 @@ mkdocs==1.6.1
71
66
  # mkdocs-material
72
67
  mkdocs-get-deps==0.2.0
73
68
  # via mkdocs
74
- mkdocs-material==9.6.8
69
+ mkdocs-material==9.6.15
75
70
  # via mkapi
76
71
  mkdocs-material-extensions==1.3.1
77
72
  # via mkdocs-material
78
73
  nodeenv==1.9.1
79
74
  # via pre-commit
80
- packaging==24.2
75
+ packaging==25.0
81
76
  # via
82
77
  # mkdocs
83
78
  # pytest
@@ -87,33 +82,35 @@ paramiko==3.5.1
87
82
  # via sshtunnel
88
83
  pathspec==0.12.1
89
84
  # via mkdocs
90
- platformdirs==4.3.6
85
+ platformdirs==4.3.8
91
86
  # via
92
87
  # mkdocs-get-deps
93
88
  # virtualenv
94
- pluggy==1.5.0
95
- # via pytest
96
- pre-commit==4.1.0
89
+ pluggy==1.6.0
90
+ # via
91
+ # pytest
92
+ # pytest-cov
93
+ pre-commit==4.2.0
97
94
  # via hdx-python-database (pyproject.toml)
98
- psycopg==3.2.6
95
+ psycopg==3.2.9
99
96
  # via hdx-python-database (pyproject.toml)
100
- psycopg-binary==3.2.6
97
+ psycopg-binary==3.2.9
101
98
  # via psycopg
102
99
  pycparser==2.22
103
100
  # via cffi
104
- pygments==2.19.1
101
+ pygments==2.19.2
105
102
  # via
106
103
  # mkdocs-material
107
- # rich
108
- pymdown-extensions==10.14.3
104
+ # pytest
105
+ pymdown-extensions==10.16
109
106
  # via mkdocs-material
110
107
  pynacl==1.5.0
111
108
  # via paramiko
112
- pytest==8.3.5
109
+ pytest==8.4.1
113
110
  # via
114
111
  # hdx-python-database (pyproject.toml)
115
112
  # pytest-cov
116
- pytest-cov==6.0.0
113
+ pytest-cov==6.2.1
117
114
  # via hdx-python-database (pyproject.toml)
118
115
  python-dateutil==2.9.0.post0
119
116
  # via ghp-import
@@ -124,25 +121,21 @@ pyyaml==6.0.2
124
121
  # pre-commit
125
122
  # pymdown-extensions
126
123
  # pyyaml-env-tag
127
- pyyaml-env-tag==0.1
124
+ pyyaml-env-tag==1.1
128
125
  # via mkdocs
129
- requests==2.32.3
126
+ requests==2.32.4
130
127
  # via mkdocs-material
131
- rich==13.9.4
132
- # via mkapi
133
128
  six==1.17.0
134
129
  # via python-dateutil
135
- sqlalchemy==2.0.39
130
+ sqlalchemy==2.0.41
136
131
  # via hdx-python-database (pyproject.toml)
137
132
  sshtunnel==0.4.0
138
133
  # via hdx-python-database (pyproject.toml)
139
- typing-extensions==4.12.2
140
- # via
141
- # psycopg
142
- # sqlalchemy
143
- urllib3==2.3.0
134
+ typing-extensions==4.14.1
135
+ # via sqlalchemy
136
+ urllib3==2.5.0
144
137
  # via requests
145
- virtualenv==20.29.3
138
+ virtualenv==20.32.0
146
139
  # via pre-commit
147
140
  watchdog==6.0.0
148
141
  # via mkdocs
@@ -1,4 +1,3 @@
1
- line-length = 79
2
1
  exclude = ["_version.py"]
3
2
 
4
3
  [lint]
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '1.3.6'
21
- __version_tuple__ = version_tuple = (1, 3, 6)
20
+ __version__ = version = '1.3.7'
21
+ __version_tuple__ = version_tuple = (1, 3, 7)
@@ -281,17 +281,15 @@ class Database:
281
281
  engine = create_engine(db_uri, poolclass=NullPool, echo=False)
282
282
  if reflect:
283
283
  Base = automap_base(declarative_base=table_base)
284
- Base.prepare(
285
- autoload_with=engine, reflection_options={"views": True}
286
- )
284
+ Base.prepare(autoload_with=engine, reflection_options={"views": True})
287
285
  table_base = Base
288
286
  else:
289
287
  table_base.metadata.create_all(engine)
290
288
  return Session(engine), table_base
291
289
 
292
290
  @staticmethod
293
- def recreate_schema(engine: Engine, schema_name: str = "public") -> bool:
294
- """Wipe and create empty schema in database using SQLAlchemy.
291
+ def drop_schema(engine: Engine, schema_name: str = "public") -> bool:
292
+ """Wipe schema in database using SQLAlchemy.
295
293
 
296
294
  Args:
297
295
  engine (Engine): SQLAlchemy engine to use.
@@ -307,10 +305,30 @@ class Database:
307
305
  DropSchema(schema_name, cascade=True, if_exists=True)
308
306
  )
309
307
  connection.commit()
308
+ return True
309
+ except SQLAlchemyError:
310
+ return False
311
+
312
+ @staticmethod
313
+ def recreate_schema(engine: Engine, schema_name: str = "public") -> bool:
314
+ """Wipe and create empty schema in database using SQLAlchemy.
315
+
316
+ Args:
317
+ engine (Engine): SQLAlchemy engine to use.
318
+ schema_name (str): Schema name. Defaults to "public".
319
+
320
+ Returns:
321
+ bool: True if all successful, False if not
322
+ """
323
+ # Wipe and create an empty schema
324
+ try:
325
+ with engine.connect() as connection:
310
326
  connection.execute(
311
- CreateSchema(schema_name, if_not_exists=True)
327
+ DropSchema(schema_name, cascade=True, if_exists=True)
312
328
  )
313
329
  connection.commit()
330
+ connection.execute(CreateSchema(schema_name, if_not_exists=True))
331
+ connection.commit()
314
332
  return True
315
333
  except SQLAlchemyError:
316
334
  return False
@@ -59,6 +59,12 @@ def restore_from_pgfile(db_uri: str, pg_restore_file: str) -> str:
59
59
  str: Output from the pg_restore command
60
60
  """
61
61
  db_params = get_params_from_connection_uri(db_uri)
62
+ if pg_restore_file[-3:] == ".xz":
63
+ decompress = subprocess.Popen(
64
+ ("unxz", "-c", "-d", pg_restore_file), stdout=subprocess.PIPE
65
+ ).stdout
66
+ else:
67
+ decompress = None
62
68
  subprocess_params = ["pg_restore", "-c"]
63
69
  for key, value in db_params.items():
64
70
  match key:
@@ -74,13 +80,18 @@ def restore_from_pgfile(db_uri: str, pg_restore_file: str) -> str:
74
80
  continue
75
81
  subprocess_params.append(f"{value}")
76
82
 
77
- subprocess_params.append(f"{pg_restore_file}")
83
+ if not decompress:
84
+ subprocess_params.append(pg_restore_file)
78
85
  env = environ.copy()
79
86
  password = db_params.get("password")
80
87
  if password:
81
88
  env["PGPASSWORD"] = password
82
89
  process = subprocess.run(
83
- subprocess_params, env=env, capture_output=True, encoding="utf-8"
90
+ subprocess_params,
91
+ env=env,
92
+ capture_output=True,
93
+ encoding="utf-8",
94
+ stdin=decompress,
84
95
  )
85
96
  try:
86
97
  process.check_returncode()
@@ -13,7 +13,5 @@ def camel_to_snake_case(string: str) -> str:
13
13
  Returns:
14
14
  str: String in snake case
15
15
  """
16
- string = re.sub(
17
- r"((?<=[a-z0-9])[A-Z]|(?!^)[A-Z](?=[a-z]))", r"_\1", string
18
- )
16
+ string = re.sub(r"((?<=[a-z0-9])[A-Z]|(?!^)[A-Z](?=[a-z]))", r"_\1", string)
19
17
  return string.lower().lstrip("_")
@@ -45,9 +45,7 @@ class TestDatabase:
45
45
  now = datetime(2023, 10, 20, 22, 35, 55, tzinfo=timezone.utc)
46
46
  rows = [{"test_date": now}]
47
47
  dbdatabase.batch_populate(rows, DBTestDate)
48
- dbtestdate = (
49
- dbsession.execute(select(DBTestDate)).all()[1][0].test_date
50
- )
48
+ dbtestdate = dbsession.execute(select(DBTestDate)).all()[1][0].test_date
51
49
  assert dbtestdate == now
52
50
 
53
51
  remove(dbpath)
@@ -17,9 +17,7 @@ class TestDBURI:
17
17
  "dialect": "postgresql",
18
18
  "driver": "psycopg",
19
19
  }
20
- connection_uri_pg = (
21
- "postgresql+psycopg://myuser:mypass@myserver:1234/mydatabase"
22
- )
20
+ connection_uri_pg = "postgresql+psycopg://myuser:mypass@myserver:1234/mydatabase"
23
21
  params_pg_no_driver = {
24
22
  "database": "mydatabase",
25
23
  "host": "myserver",
@@ -37,9 +35,7 @@ class TestDBURI:
37
35
  "dialect": "postgresql",
38
36
  "driver": None,
39
37
  }
40
- connection_uri_pg_no_driver = (
41
- "postgresql://myuser:mypass@myserver:1234/mydatabase"
42
- )
38
+ connection_uri_pg_no_driver = "postgresql://myuser:mypass@myserver:1234/mydatabase"
43
39
  params_sq_no_driver = {
44
40
  "database": "mydatabase",
45
41
  "host": "myserver",
@@ -67,9 +63,7 @@ class TestDBURI:
67
63
  include_driver=False,
68
64
  )
69
65
  assert result == TestDBURI.params_pg_no_driver
70
- result = get_params_from_connection_uri(
71
- TestDBURI.connection_uri_pg_no_driver
72
- )
66
+ result = get_params_from_connection_uri(TestDBURI.connection_uri_pg_no_driver)
73
67
  assert result == TestDBURI.params_pg_driver_none
74
68
  result = get_params_from_connection_uri(TestDBURI.connection_uri_sq)
75
69
  assert result == TestDBURI.params_sq_driver_none
@@ -77,9 +71,7 @@ class TestDBURI:
77
71
  def test_get_connection_uri(self):
78
72
  result = get_connection_uri(**TestDBURI.params_pg)
79
73
  assert result == TestDBURI.connection_uri_pg
80
- result = get_connection_uri(
81
- **TestDBURI.params_pg, include_driver=False
82
- )
74
+ result = get_connection_uri(**TestDBURI.params_pg, include_driver=False)
83
75
  assert result == TestDBURI.connection_uri_pg_no_driver
84
76
  result = get_connection_uri(**TestDBURI.params_pg_no_driver)
85
77
  assert result == TestDBURI.connection_uri_pg
@@ -1,6 +1,13 @@
1
1
  from hdx.database import Database
2
2
 
3
3
 
4
+ def test_drop_schema(mock_engine):
5
+ db_uri = "postgresql+psycopg://myuser:mypass@0.0.0.0:12345/mydatabase"
6
+ assert Database.drop_schema(mock_engine, db_uri) is True
7
+ db_uri = "Error"
8
+ assert Database.drop_schema(mock_engine, db_uri) is False
9
+
10
+
4
11
  def test_recreate_schema(mock_engine):
5
12
  db_uri = "postgresql+psycopg://myuser:mypass@0.0.0.0:12345/mydatabase"
6
13
  assert Database.recreate_schema(mock_engine, db_uri) is True
@@ -53,9 +53,7 @@ class TestSSH:
53
53
  )
54
54
  assert dbdatabase._base == NoTZBase
55
55
 
56
- with Database(
57
- ssh_host="mysshhost", ssh_port=25, **params
58
- ) as dbdatabase:
56
+ with Database(ssh_host="mysshhost", ssh_port=25, **params) as dbdatabase:
59
57
  dbsession = dbdatabase.get_session()
60
58
  assert (
61
59
  str(dbsession.bind.engine.url)