Skip to content

Commit

Permalink
Update d1.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Nickwasused committed Oct 31, 2024
1 parent d3eefbb commit 2550e36
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions d1.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
from cloudflare import Cloudflare
from cloudflare import Cloudflare, APIConnectionError, RateLimitError, APIStatusError
from pathlib import Path
from json import load
import os
Expand Down Expand Up @@ -60,7 +60,17 @@ def export_stations():
querys.append("".join(tmp_query))
tmp_query = []
for query in querys:
client.d1.database.query(account_id=os.environ.get("CF_ACCOUNT_ID"), database_id=os.environ.get("CF_DATABASE_ID"), sql=query)
try:
client.d1.database.query(account_id=os.environ.get("CF_ACCOUNT_ID"), database_id=os.environ.get("CF_DATABASE_ID"), sql=query)
except APIConnectionError as e:
print("The server could not be reached")
print(e.__cause__) # an underlying Exception, likely raised within httpx.
except RateLimitError as e:
print("A 429 status code was received; we should back off a bit.")
except APIStatusError as e:
print("Another non-200-range status code was received")
print(e.status_code)
print(e.response)


if __name__ == "__main__":
Expand Down

0 comments on commit 2550e36

Please sign in to comment.