mirror of
https://github.com/correl/mtgsqlive.git
synced 2024-11-22 03:00:10 +00:00
Price value validation added. (#35)
This commit is contained in:
parent
7139f36241
commit
559d07b55d
1 changed files with 18 additions and 15 deletions
|
@ -179,7 +179,6 @@ def build_sql_schema(output_file: Dict) -> None:
|
||||||
"variations TEXT,",
|
"variations TEXT,",
|
||||||
"watermark TEXT",
|
"watermark TEXT",
|
||||||
");",
|
");",
|
||||||
# "CREATE UNIQUE INDEX 'cards_uuid' ON cards(uuid);"
|
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
],
|
],
|
||||||
|
@ -481,15 +480,15 @@ def handle_price_rows(
|
||||||
for price_type in card_data["prices"]:
|
for price_type in card_data["prices"]:
|
||||||
if card_data["prices"][price_type] is not None:
|
if card_data["prices"][price_type] is not None:
|
||||||
for date, price in card_data["prices"][price_type].items():
|
for date, price in card_data["prices"][price_type].items():
|
||||||
prices.append(
|
if price:
|
||||||
{
|
prices.append(
|
||||||
"uuid": card_uuid,
|
{
|
||||||
"type": price_type,
|
"uuid": card_uuid,
|
||||||
"price": price,
|
"type": price_type,
|
||||||
"date": date,
|
"price": price,
|
||||||
}
|
"date": date,
|
||||||
)
|
}
|
||||||
|
)
|
||||||
return prices
|
return prices
|
||||||
|
|
||||||
|
|
||||||
|
@ -628,8 +627,12 @@ def sql_dict_insert(data: Dict[str, Any], table: str, output_file: Dict) -> None
|
||||||
query = query.format(**data)
|
query = query.format(**data)
|
||||||
output_file["handle"].write(query)
|
output_file["handle"].write(query)
|
||||||
else:
|
else:
|
||||||
cursor = output_file["handle"].cursor()
|
try:
|
||||||
columns = ", ".join(data.keys())
|
cursor = output_file["handle"].cursor()
|
||||||
placeholders = ":" + ", :".join(data.keys())
|
columns = ", ".join(data.keys())
|
||||||
query = f"INSERT INTO {table} ({columns}) VALUES ({placeholders})"
|
placeholders = ":" + ", :".join(data.keys())
|
||||||
cursor.execute(query, data)
|
query = f"INSERT INTO {table} ({columns}) VALUES ({placeholders})"
|
||||||
|
cursor.execute(query, data)
|
||||||
|
except:
|
||||||
|
datastr = str(data)
|
||||||
|
LOGGER.warning(f"Failed to insert row in {table} with values {datastr}")
|
||||||
|
|
Loading…
Reference in a new issue