Created
February 26, 2021 19:56
-
-
Save iEv0lv3/92f41b889d957372d5048229829c45c1 to your computer and use it in GitHub Desktop.
BrightView SQL Query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def query_database( | |
self, | |
table, | |
limit=1000, | |
offset=0, | |
limit_key='last_operation_time', | |
limit_key_value='2000-01-11 00:00:00.000000' | |
): | |
if table == 'procedure': | |
self.sql.execute( | |
'SELECT * ' + | |
f"FROM 'procedure' " + | |
f'WHERE {limit_key} >= "{limit_key_value}" ' + | |
f'ORDER BY {limit_key}, procedure_id ' + | |
f'LIMIT {limit} OFFSET {offset}' | |
) | |
query = self.sql.fetchall() | |
return query | |
self.sql.execute( | |
'SELECT * ' + | |
f'FROM {table} ' + | |
f'WHERE {limit_key} >= "{limit_key_value}" ' + | |
f'ORDER BY {limit_key}, {table}_id ' + | |
f'LIMIT {limit} OFFSET {offset}' | |
) | |
query = self.sql.fetchall() | |
return query |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment