Worker
Helper Functions¶
find_single_row¶
Return first item from a SQL query result. This will NOT return a row, but literall the very first item.
Example:
select "hello" as `col_1`, "goodbye" as `col_2`;
query = 'select "hello" as `col_1`, "goodbye" as `col_2`;'
val = find_single_row(query, conn)
print(val)
hello
find_single_full_row¶
This will return the first row found as an array of items.
Using example above:
query = 'select "hello" as `col_1`, "goodbye" as `col_2`;'
val = find_single_full_row(query, conn)
print(val)
['hello', 'goodbye']
dictfetchall¶
Heavy handed so shouldn't be used as often as previous two. This will convert an entire sql result(s) into an array of key:value dictionaries.
Using example above:
query = 'select "hello" as `col_1`, "goodbye" as `col_2`;'
val = find_single_full_row(query, conn)
print(val)
[{ 'col_1': 'hello', 'col_2': 'goodbye' }]