mirror of
https://github.com/jaypyles/Scraperr.git
synced 2025-11-10 03:14:41 +00:00
* chore: refactor wip * chore: refactor wip * chore: refactor wip * chore: refactor wip * chore: refactor wip * chore: refactor wip * chore: work in progress * chore: work in progress * chore: work in progress * chore: work in progress * chore: work in progress * chore: work in progress * chore: work in progress * chore: work in progress * chore: work in progress * chore: refactor wip * chore: work in progress * chore: refactor wip * chore: refactor wip * chore: refactor wip * fix: build * fix: cypress test * fix: cypress test * fix: cypress test * fix: cypress test * fix: cypress test * fix: cypress test * fix: cypress test * fix: cypress test * fix: cypress tests * fix: cypress tests * fix: cypress tests * fix: cypress tests * fix: cypress tests * fix: cypress tests * fix: cypress tests * fix: cypress tests * fix: cypress tests * fix: cypress tests * fix: cypress tests * fix: cypress tests * fix: cypress tests * fix: cypress tests * fix: cypress tests * fix: cypress tests * fix: cypress tests
31 lines
764 B
Python
31 lines
764 B
Python
# STL
|
|
import json
|
|
from typing import Any
|
|
|
|
|
|
def format_list_for_query(ids: list[str]):
|
|
return (
|
|
f"({','.join(['?' for _ in ids])})" # Returns placeholders, e.g., "(?, ?, ?)"
|
|
)
|
|
|
|
|
|
def format_sql_row_to_python(row: dict[str, Any]):
|
|
new_row: dict[str, Any] = {}
|
|
for key, value in row.items():
|
|
if isinstance(value, str):
|
|
try:
|
|
new_row[key] = json.loads(value)
|
|
except json.JSONDecodeError:
|
|
new_row[key] = value
|
|
else:
|
|
new_row[key] = value
|
|
|
|
return new_row
|
|
|
|
|
|
def format_json(items: list[Any]):
|
|
for idx, item in enumerate(items):
|
|
if isinstance(item, (dict, list)):
|
|
formatted_item = json.dumps(item)
|
|
items[idx] = formatted_item
|