Back

[SOLVED] Export Entire Data of Collection

  • 0
  • Databases
  • Self Hosted
hosnipogi
2 Mar, 2023, 08:34

Hello, is there an easy way to export the entire data of just a single collection using the cli or docker mariadb commands other than querying from api?

Example I have a Tasks and Projects collection, I just want to export all data from the Tasks collection using cli.

TL;DR
The user wanted to export the entire data of a collection without using the API. They found a solution using a Docker command to echo the data from the MariaDB container and saved it to a CSV file. They also mentioned a GitHub repository with a cloud function that can export collection data to a CSV file.
rafagazani
2 Mar, 2023, 14:53

I did this with cloud function. it goes through all the documents of a collection and inserts in a csv. At the end save the file in storage. Help you?

rafagazani
9 Mar, 2023, 12:24

@hosni.hotelkilow can we Mark it as solved?

hosnipogi
9 Mar, 2023, 14:34

Hello! Sorry I forgot to get back, thank you for this snippet ill use it as reference soon. In the end what I did was to echo out from the mariadb container as I did't want to call the api for it, I had to figure out the correct table name though

TypeScript
docker exec appwrite-mariadb sh -c 'exec mysql -B -u"$MYSQL_USER" -p"$MYSQL_PASSWORD" appwrite -e "SELECT * FROM _1_database_1_collection_6;"' \
| sed "s/\"/\"\"/g;s/'/\'/;s/\t/\",\"/g;s/^/\"/;s/$/\"/;s/\n//g" > medias.csv
hosnipogi
9 Mar, 2023, 14:35

[SOLVED] Export Entire Data of Collection

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