Support for DECIMAL precision in Database Manager

Hi, i would like to consume data from an api and store it into the database table. using API Data Source i have managed to get the data but how i can save that data into the database? is there any docs available for that? or if anyone know the step that i need to follow please let me know here. thanks

Hi.

You need to create a server action (API) from the left panel, and consume your API there. In the same server action, you can also save response from API into a DB table.

1 Like

i could not find the way to do, there is API connector and API action which i can consume the data. but there is no option or any other way to save the response to a database table. could you please explain bit more, if possible with screenshot. thanks

What documentation have you referred. The process is explained across different docs.
What you are talking about is client side components.
To do any DB related transactions, you need the server side component available via API section on the left panel.

Take a look here: https://docsdev.wappler.io/

1 Like

You need to setup your API connection in a server action, then loop through the results using a repeat step and add the database insert step inside the repeat, so it can add each of the records to the database.

1 Like

i have done as you said, but could you please tell me how do i trigger the server action to get the data from api and store, i did tried out like using server connect on my index page and selected the server action which has api request and repeater used, but in my table i only got incremented id not other field values. i’m i doing wrong somewhere in the flow?

Please add some screenshots of what are you doing exactly so we can see what’s wrong.

This looks good to me. So what’s the issue? The insert step is not inserting the value?
If that’s the case then do you see any data actually returned from the API when you check the server action response in the network tab of dev tools?

is it correct that i’m using the server connect in client side(in my index page) and selecting this server action which get the data from api and insert into table ?

Well you have to call the server action somehow, so calling it / loading it from the page is fine.
I don’t know if you API requires you to send some data to it when calling it…

the API is returning the data like this, i got 200 status anyway.

    {
  "success": true,
  "timestamp": 1632172744,
  "source": "GBP",
  "quotes": {
    "GBPEUR": 1.164629,
    "GBPUSD": 1.365653,
    "GBPJPY": 149.386077
  }
}

API Schema Editor right side screenshot:

in here what i’m trying to insert into database is “quotes” object, so i made the table which has one string field and number field

Hi Teodor, i got result like this on the browser network tab on dev tools. i still could not figure out how can i map the database field and the api data object fields. any idea?

please help, if anyone else know how can i use API Connector and repeat to save the data from api to database table. i’m stuck…

What is your entire api response/schema and which part of it exactly do you want to insert in the database?


above screen shot shows the response from the API, first screenshot shows data object which has quotes object (second screenshot shows bit closer), i wanted to save to quotes object first, such as the values like GBPEUR: 1.16468, in the database i wanted this “GBPEUR” to be in a text field, and then value 1.16468 to be in decimal number field or respective field which can hold exact same value.

the problem with this API is that it doesn’t return an array with the values, but an object so you can’t just repeat and select the values.
So you need a repeat which repeats the quotes object as you did in the screenshots above, but in the insert step you need to get the $key - for the currency code and $value for the currency rate from the object.
So just in the insert step use {{$key}} and {{$value}} (manually enter them in the values for currency code and currency rate:

1 Like

Yes it worked :slight_smile: great Teodor, one clarification why there is no $key and $value when i wanted to pick from the response? but one issue i get, the value is rounded not exact value is stored in db. how do i resolve that? formatter?