Hello!
I am currently struggling to insert data into my DB.
I have an empty table which automatically adds the ID for each new entry that I make.
I now want to add data to said Table Keyword, which only has two columns, them being keyword_id and name (Im rather new to sql and databases but I am aware that these names might not be proper etiquette). I prepared the data I want to insert into the table in MS Excel, converted the file into a csv. format, uploaded it into a table and am now trying to insert said data into my DB.
I already tried to use the gui bulk function of retool but I cannot seem to get the array format right as the table.data returns an additional entry which I initially didnt enter:
I also tried to enter the data without the ID but the issue, being the "" entries, kept persisting.
I also used a the map function to get just the keywords but I still received an error. Upon doing my research it semmed that the array entries were objects and not strings but I don't know how I could vonvert them to strings.
My next attempt was to enter the data one by one by iterating through the table. This not only took a long time but also yielded no results as I dont know how to set up the query and trigger it via additional scopes to enter the data:
const keywords = table1.data;
// Loop through each row and trigger the insert query for each keyword
for (let i = 0; i < keywords.length; i++) {
await keyword.setValue(keywords[i].Keyword); // Assuming each row has a "Keyword" column
console.log(await keyword.value)
//Trigger the insert query for each keyword
await bulkinsert.trigger({
additionalScope: {
keyword: await keyword.value // Pass the keyword into the query
}
});
}
I get the error:
My query looks as follows:
INSERT INTO Keyword
VALUES ({{ keyword.value }})
I am at a loss.
On why I only want to enter the keyword: As the id automatically increments I figured just entering the name would suffice.
Thank you for our help in advance!