HTTP JSON > Database > Help

Hello,

Thank you in advance for the help.

I’ve hit a brick wall of research and im unable to move forward and I’m hoping someone can help me.

Goal: Retreive JSON data through HTTP and post into a database.

Problem: I have no idea how to transfer the records from the code module into a database. I’m hoping I can simply run a piece that will transfer each record into MySQL but I don’t know how to do that at this time.

Where I’m At:
HTTP Req >
Replace (I’m only using this as it reformats and fixes a JSON error, it doesnt actually do anything) >
Todays Date >
Custom Javascript (Remove data I won’t want to keep) >
export const code = async (inputs) => {
// Parse the input content
const data = JSON.parse(inputs.content);

// Remove `adjusted_price` field from each object in the array
const updatedData = data.map(({ adjusted_price, ...rest }) => rest);

// Return the modified data
return updatedData;

};

Result: 15024 records in the following format:
[
{
“average_price”: 31813333.33,
“type_id”: 43691
},
{
“average_price”: 678384.99,
“type_id”: 32772
},

My MySQL table is setup to have an auto-increment ID, date, average_price and type_id.

I’m hoping to “simply” post the data from the code piece JSON into MySQL in full so that I can then poll the information from the database.

I have ran the Insert Row MySQL piece pointing to single records of the code piece and it was succesful.

image

I have tried using the storage piece but the dataset is above 512kb.

Any help is appreciated, thank you.

Hello @Darklink , You can use Loop piece to iterate over all of the records from Code step and insert them in MySQL step.