Add SQL template for Python v2
Add template here: https://github.com/Azure/azure-functions-templates/tree/dev/Functions.Templates/Templates-v2
Is it possible to add multiple rows to the database in one go?
Yes, in Python you can use SqlRowList to add multiple rows. See this sample: https://github.com/Azure/azure-functions-sql-extension/blob/3a5971284fc6bb6dc0d16e4d10f159220de4e9a2/samples/samples-python/AddProductsArray/init.py#L16
@LouisDeconinck, this seems like a functions error, not specific to SQL Bindings. Could you file an issue in the Azure Functions Host repository?
@lucyzhang929 I'm running into another issue. Getting the following error:
Database on server is not currently available. Please retry the connection later. If the problem persists, contact customer support, and provide them the session tracing ID of '{C16638E0-26B4-4AB7-B831-19F334051195}'.
Is there anyway how I can detect that the database will not be available and retry writing another time?
I have the following code, but this doesn't work as I believe that the .set() happens asynchronously after the function has already ended.
max_retries = 10
retries = 0
while retries < max_retries:
try:
r.set(rows_sql)
total_time = time.time() - start_time
logging.info(f"End of scraping. Scraped {len(rows)} groups in {total_time}.")
break
except Exception as e:
logging.error(f"An error occurred: {str(e)}")
retries += 1
if retries < max_retries:
logging.info(f"Retrying after 30 seconds... (retry {retries}/{max_retries})")
time.sleep(30)
else:
logging.error(f"An error occurred: {str(e)}")
@LouisDeconinck Can you create a separate issue for your question please? https://github.com/Azure/azure-functions-sql-extension/issues/new/choose Thank you!