Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified diagrams/erdiagram_targetdb_latest.pdf
Binary file not shown.
4 changes: 2 additions & 2 deletions docs/tbls/public.fluxstd.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@
| fluxstd_pkey | CREATE UNIQUE INDEX fluxstd_pkey ON public.fluxstd USING btree (fluxstd_id) |
| uq_obj_id_input_catalog_id_version | CREATE UNIQUE INDEX uq_obj_id_input_catalog_id_version ON public.fluxstd USING btree (obj_id, input_catalog_id, version) |
| ix_fluxstd_version_fluxstdid | CREATE INDEX ix_fluxstd_version_fluxstdid ON public.fluxstd USING btree (version, fluxstd_id) |
| fluxstd_q3c_ang2ipix_idx | CREATE INDEX fluxstd_q3c_ang2ipix_idx ON public.fluxstd USING btree (q3c_ang2ipix(ra, "dec")) |
| ix_fluxstd_input_catalog_fluxstdid | CREATE INDEX ix_fluxstd_input_catalog_fluxstdid ON public.fluxstd USING btree (input_catalog_id, fluxstd_id) |
| ix_fluxstd_version | CREATE INDEX ix_fluxstd_version ON public.fluxstd USING btree (version) |
| ix_fluxstd_input_catalog_fluxstdid | CREATE INDEX ix_fluxstd_input_catalog_fluxstdid ON public.fluxstd USING btree (input_catalog_id, fluxstd_id) |
| fluxstd_q3c_ang2ipix_idx | CREATE INDEX fluxstd_q3c_ang2ipix_idx ON public.fluxstd USING btree (q3c_ang2ipix(ra, "dec")) |

## Relations

Expand Down
2 changes: 1 addition & 1 deletion docs/tbls/public.sky.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
| sky_pkey | CREATE UNIQUE INDEX sky_pkey ON public.sky USING btree (sky_id) |
| sky_obj_id_input_catalog_id_version_key | CREATE UNIQUE INDEX sky_obj_id_input_catalog_id_version_key ON public.sky USING btree (obj_id, input_catalog_id, version) |
| sky_q3c_ang2ipix_idx | CREATE INDEX sky_q3c_ang2ipix_idx ON public.sky USING btree (q3c_ang2ipix(ra, "dec")) |
| ix_sky_version | CREATE INDEX ix_sky_version ON public.sky USING btree (version) |
| ix_sky_input_catalog_id | CREATE INDEX ix_sky_input_catalog_id ON public.sky USING btree (input_catalog_id) |
| ix_sky_version | CREATE INDEX ix_sky_version ON public.sky USING btree (version) |

## Relations

Expand Down
20 changes: 19 additions & 1 deletion src/targetdb/targetdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,27 @@ def connect(self):
# print('connection to {0} started'.format(self.dbinfo))

def close(self):
self.session.close()
try:
self.session.close()
finally:
# Dispose the engine to release all pooled connections back to the database
# server. Without this, SQLAlchemy's connection pool keeps the underlying
# TCP sockets open until the engine is garbage-collected, which may never
# happen on abnormal process termination.
self.engine.dispose()
# print('connection to {0} closed'.format(self.dbinfo))

def __enter__(self):
"""Support usage as a context manager: ``with TargetDB(...) as db:``."""
if not hasattr(self, "session"):
self.connect()
return self
Comment thread
monodera marked this conversation as resolved.

def __exit__(self, exc_type, exc_val, exc_tb):
"""Ensure close() is called even if an exception occurs inside the block."""
self.close()
return False # re-raise any exception

def reset_all(self, full=True):
#
# Order of the resetting tables is important
Expand Down