Skip to content

Instantly share code, notes, and snippets.

@iEv0lv3
Created February 26, 2021 19:56
Show Gist options
  • Save iEv0lv3/92f41b889d957372d5048229829c45c1 to your computer and use it in GitHub Desktop.
Save iEv0lv3/92f41b889d957372d5048229829c45c1 to your computer and use it in GitHub Desktop.
BrightView SQL Query
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