|
8 | 8 | import numpy as np |
9 | 9 | import pandas as pd |
10 | 10 | from .connection import Connection |
| 11 | +from forest import mark |
11 | 12 |
|
12 | 13 |
|
13 | 14 | __all__ = [ |
@@ -373,9 +374,9 @@ def insert_pressure(self, path, variable, pressure, i): |
373 | 374 | (SELECT id FROM pressure WHERE value=:pressure AND i=:i)) |
374 | 375 | """, dict(path=path, variable=variable, pressure=pressure, i=i)) |
375 | 376 |
|
| 377 | + @mark.sql_sanitize_time("initial_time") |
376 | 378 | def valid_times(self, pattern, variable, initial_time): |
377 | 379 | """Valid times associated with search criteria""" |
378 | | - initial_time = self.sanitize_time(initial_time) |
379 | 380 | query = self.valid_times_query(pattern, variable, initial_time) |
380 | 381 | self.cursor.execute(query, dict( |
381 | 382 | variable=variable, |
@@ -417,22 +418,9 @@ def valid_times_query(pattern, variable, initial_time): |
417 | 418 | variable=variable, |
418 | 419 | pattern=pattern) |
419 | 420 |
|
420 | | - @staticmethod |
421 | | - def sanitize_time(value): |
422 | | - """Query-compatible equivalent of value""" |
423 | | - fmt = "%Y-%m-%d %H:%M:%S" |
424 | | - if value is None: |
425 | | - return value |
426 | | - elif isinstance(value, str): |
427 | | - return value |
428 | | - elif isinstance(value, np.datetime64): |
429 | | - return pd.to_datetime(str(value)).strftime(fmt) |
430 | | - else: |
431 | | - return value.strftime(fmt) |
432 | | - |
| 421 | + @mark.sql_sanitize_time("initial_time") |
433 | 422 | def pressures(self, pattern=None, variable=None, initial_time=None): |
434 | 423 | """Select pressures from database""" |
435 | | - initial_time = self.sanitize_time(initial_time) |
436 | 424 | query = self.pressures_query(pattern, variable, initial_time) |
437 | 425 | self.cursor.execute(query, dict( |
438 | 426 | variable=variable, |
|
0 commit comments