|
@@ -91,8 +91,8 @@ class InfluxdbHandler:
|
|
|
|
|
|
def query_between_dates(self, columns: str,
|
|
def query_between_dates(self, columns: str,
|
|
tables: str,
|
|
tables: str,
|
|
- start: str,
|
|
|
|
- stop: str) -> pd.DataFrame:
|
|
|
|
|
|
+ start: str = None,
|
|
|
|
+ stop: str = None) -> pd.DataFrame:
|
|
"""
|
|
"""
|
|
:param columns: DESCRIPTION
|
|
:param columns: DESCRIPTION
|
|
:type columns: str
|
|
:type columns: str
|
|
@@ -106,21 +106,35 @@ class InfluxdbHandler:
|
|
:rtype: TYPE
|
|
:rtype: TYPE
|
|
|
|
|
|
"""
|
|
"""
|
|
- if not isinstance(start, str):
|
|
|
|
|
|
+ if (start is not None) and (not isinstance(start, str)):
|
|
start = datetime.strftime(start, format="%Y-%m-%dT%H:%M:%SZ")
|
|
start = datetime.strftime(start, format="%Y-%m-%dT%H:%M:%SZ")
|
|
|
|
|
|
- if not isinstance(stop, str):
|
|
|
|
|
|
+ if (stop is not None) and (not isinstance(stop, str)):
|
|
stop = datetime.strftime(stop, format="%Y-%m-%dT%H:%M:%SZ")
|
|
stop = datetime.strftime(stop, format="%Y-%m-%dT%H:%M:%SZ")
|
|
-
|
|
|
|
- query = 'SELECT ' +\
|
|
|
|
- columns +\
|
|
|
|
- ' FROM \"' +\
|
|
|
|
- tables +\
|
|
|
|
- '\" WHERE time > \'' +\
|
|
|
|
|
|
+
|
|
|
|
+ query = 'SELECT ' + columns + ' FROM \"' + tables
|
|
|
|
+
|
|
|
|
+ if (start is not None) and (stop is not None):
|
|
|
|
+
|
|
|
|
+ query += '\" WHERE time > \'' +\
|
|
str(start) +\
|
|
str(start) +\
|
|
'\' AND time < \'' +\
|
|
'\' AND time < \'' +\
|
|
str(stop) +\
|
|
str(stop) +\
|
|
'\' tz(\'Europe/Berlin\');'
|
|
'\' tz(\'Europe/Berlin\');'
|
|
|
|
+
|
|
|
|
+ elif start is not None:
|
|
|
|
+
|
|
|
|
+ query += '\" WHERE time >= \'' + str(start) +\
|
|
|
|
+ '\' tz(\'Europe/Berlin\');'
|
|
|
|
+
|
|
|
|
+ elif stop is not None:
|
|
|
|
+
|
|
|
|
+ query += '\" WHERE time <= \'' + str(stop) +\
|
|
|
|
+ '\' tz(\'Europe/Berlin\');'
|
|
|
|
+
|
|
|
|
+ else:
|
|
|
|
+ query += ';'
|
|
|
|
+
|
|
|
|
|
|
return self.query_to_dataframe(query)
|
|
return self.query_to_dataframe(query)
|
|
|
|
|