|
13 | 13 |
|
14 | 14 | import click
|
15 | 15 | import pandas
|
16 |
| -from peewee import SQL, DoesNotExist, fn |
17 |
| - |
| 16 | +from peewee import SQL, DoesNotExist, ProgrammingError, fn |
18 | 17 |
|
19 | 18 | __all__ = [
|
20 | 19 | "Timer",
|
@@ -54,7 +53,9 @@ def elapsed(self):
|
54 | 53 | return time.time() - self.start
|
55 | 54 |
|
56 | 55 |
|
57 |
| -def sql_apply_pm(ra_field, dec_field, pmra_field, pmdec_field, epoch_delta, is_pmra_cos=True): |
| 56 | +def sql_apply_pm( |
| 57 | + ra_field, dec_field, pmra_field, pmdec_field, epoch_delta, is_pmra_cos=True |
| 58 | +): |
58 | 59 | """Constructs a SQL expression for applying proper motions to RA/Dec.
|
59 | 60 |
|
60 | 61 | Parameters
|
@@ -221,7 +222,12 @@ def set_config_parameter(database, parameter, new_value, reset=True, log=None):
|
221 | 222 |
|
222 | 223 |
|
223 | 224 | def remove_version(
|
224 |
| - database, plan, schema="catalogdb", table="catalog", delete_version=True, vacuum=True |
| 225 | + database, |
| 226 | + plan, |
| 227 | + schema="catalogdb", |
| 228 | + table="catalog", |
| 229 | + delete_version=True, |
| 230 | + vacuum=True, |
225 | 231 | ):
|
226 | 232 | """Removes all rows in ``table`` and ``table_to_`` that match a version."""
|
227 | 233 |
|
@@ -279,10 +285,14 @@ def remove_version(
|
279 | 285 | print("Removed entry in 'version'.")
|
280 | 286 |
|
281 | 287 |
|
282 |
| -def vacuum_table(database, table_name, vacuum=True, analyze=True, maintenance_work_mem="50GB"): |
| 288 | +def vacuum_table( |
| 289 | + database, table_name, vacuum=True, analyze=True, maintenance_work_mem="50GB" |
| 290 | +): |
283 | 291 | """Vacuums and analyses a table."""
|
284 | 292 |
|
285 |
| - statement = ("VACUUM " if vacuum else "") + ("ANALYZE " if analyze else "") + table_name |
| 293 | + statement = ( |
| 294 | + ("VACUUM " if vacuum else "") + ("ANALYZE " if analyze else "") + table_name |
| 295 | + ) |
286 | 296 |
|
287 | 297 | with database.atomic():
|
288 | 298 | # Change isolation level to allow executing commands such as VACUUM.
|
@@ -333,8 +343,11 @@ def get_configuration_values(database, parameters):
|
333 | 343 |
|
334 | 344 | with database.atomic():
|
335 | 345 | for parameter in parameters:
|
336 |
| - value = database.execute_sql(f"SHOW {parameter}").fetchone()[0] |
337 |
| - values[parameter] = value |
| 346 | + try: |
| 347 | + value = database.execute_sql(f"SHOW {parameter}").fetchone()[0] |
| 348 | + values[parameter] = value |
| 349 | + except ProgrammingError: |
| 350 | + pass |
338 | 351 |
|
339 | 352 | return values
|
340 | 353 |
|
|
0 commit comments