Get Form Recognizer data into a database

Todd 21 Reputation points
2022-08-30T22:56:41.103+00:00

Is there any examples or tutorials for getting the json data from Form Recognizer into a database? Im a newb. Thanks

Azure SQL Database
{count} vote

Accepted answer
  1. YutongTie-MSFT 45,906 Reputation points
    2022-09-02T23:54:10.387+00:00

    Hello @Todd

    Thanks for using Microsoft Q&A platform . I think you are working on Form Recognizer and you want to export your result into a database.

    For regular models there is no official tutorial about how to export JSON result to DB, but I have found some external resource which can help you.

    Step 1.
    The Azure Form Recognizer SDK for Python provides helper methods like to_dict and from_dict on the models to facilitate converting the data type in the library to and from a dictionary. You can use the dictionary you get from the to_dict method directly or convert it to JSON.

    d = [page.to_dict() for page in form_pages]  
    json_string = json.dumps(d)  
    

    Reference if you need more from SDK - https://azuresdkdocs.blob.core.windows.net/$web/python/azure-ai-formrecognizer/3.2.0b5/index.html

    Step 2
    Store the JSON file into a DB, here I am using export JSON file to SQL database as an example, please see below guidance.
    https://learn.microsoft.com/en-us/sql/relational-databases/json/store-json-documents-in-sql-tables?view=sql-server-ver15

    Then you can achieve your target - get Form Recognizer JSON data into a database. But from product point, our regular workflow is not as above, could you please share more about your scenario so that I can share it to product team to optimize this process?

    Our code sample for your reference -
    API sample https://westus.dev.cognitive.microsoft.com/docs/services/form-recognizer-api-2022-08-31/operations/AnalyzeDocument
    SDK sample https://learn.microsoft.com/en-us/azure/applied-ai-services/form-recognizer/quickstarts/get-started-v3-sdk-rest-api?pivots=programming-language-python

    I will highly recommend you to try Form Recognizer Studio as you mentioned you are new, it's very easy to use and you can avoid those steps - https://learn.microsoft.com/en-us/azure/applied-ai-services/form-recognizer/quickstarts/try-v3-form-recognizer-studio

    I hope it helps! Feel free to let me know if you have any questions.

    Regards,
    Yutong

    -Please kindly accept the answer if you feel helpful to support the community, thanks a lot.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful