Back

How to migrate SQL or CSV data to Appwrite?

  • 3
  • Databases
Faisal7
20 Apr, 2023, 13:25

i ran the function it says {csvRow: AppwriteException: document_invalid_structure, Invalid document structure: Unknown attribute: "churchId" (400)}

TL;DR
TL;DR: The user wants to know how to migrate SQL or CSV data to Appwrite. There is no clear solution provided in the thread. Suggestions include looking for solutions on Github, creating a custom function, and mapping CSV rows to Appwrite attributes. The user attempted to run a function but encountered an error related to the document structure.
Faisal7
20 Apr, 2023, 13:26

do i need to create the same attributes as in csv file or i dont need to do this

Faisal7
20 Apr, 2023, 13:26

i put inside the fileid, storageid ... my bucket and fle id

Faisal7
20 Apr, 2023, 13:32

oh i see now i must to completely edit the main

Faisal7
20 Apr, 2023, 13:33

file '' try { for (final csvRow in csvTable) { final document = await ServerAppwrite.instance.databases.createDocument( databaseId: payload['databaseId'], collectionId: payload['collectionId'], documentId: 'unique()', data: { "churchId": csvRow[0], "title": csvRow[1], "module": csvRow[2], }, ); } ''

Faisal7
20 Apr, 2023, 13:33

the data section

Faisal7
20 Apr, 2023, 13:34

so i do need to specify all the csv row as attributes in my appwrite console i think, and then map it inside data section

Faisal7
20 Apr, 2023, 13:35

is it right

rafagazani
20 Apr, 2023, 13:53

As it is an example function, you need to adapt it to your collection

Faisal7
20 Apr, 2023, 13:54

is it not possible right now with some tool maybe to just copy all the csv file and make it as appwrite collection automatically?

rafagazani
20 Apr, 2023, 14:02

I understand your need, then I will create another function

rafagazani
20 Apr, 2023, 14:03

I can't promise right now but it's relatively simple, however I'm working

Faisal7
20 Apr, 2023, 14:03

thats very nice from you thank you, but is it even possible such thing?

rafagazani
20 Apr, 2023, 14:04

very very simple, I believe that if you play this code in chatGPT and ask it to create the collection if it does not exist, it would succeed

Faisal7
20 Apr, 2023, 14:05

oh ithaught it would be difficult even not possible i thaught

Faisal7
20 Apr, 2023, 14:05

i will then try maybe i succeed

Faisal7
20 Apr, 2023, 14:06

it would be very perfect and helpful if such feauture exists in appwrite console itself.

rafagazani
20 Apr, 2023, 14:06

I think it will be more annoying to determine the type of the attribute but nothing that some if can't solve

Faisal7
20 Apr, 2023, 14:07

ok

rafagazani
20 Apr, 2023, 14:09

there are some things on github about importing and exporting data to appwrite, give it a look. I believe this feature will exist, not now but certainly will

Faisal7
20 Apr, 2023, 14:09

can you reference any link?

rafagazani
20 Apr, 2023, 14:10

I don't have it but you can look for it in the issues

Faisal7
20 Apr, 2023, 14:10

oh ok i will look then

Faisal7
20 Apr, 2023, 14:11

by the way thank you very much for your time and responces.

new user
29 Apr, 2023, 12:43

done great job, thank you for sahering

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more