Search code examples
arangodbaql

Run arangodb text file from command line


Description

In MySQL world, one can create an SQL file and execute it from the command line.

mysql -h hostname -u user database < path/to/sqlfile.sql

This is especially useful for test data.

I've checked the Arangodb documentation and the best I can see for putting in test data is this from the cookbook

https://docs.arangodb.com/3.11/aql/examples-and-query-patterns/create-test-data/

Please is it possible to write an aql file and execute it in the command line like with MySQL?


Solution

  • In contrast to mysql SQL which contains DML and DDL language elements, AQL by definition only contains DML statements. Therefore "executing AQL" is most probably not what suits your needs.

    The arangosh can be used to read files from the filesystem, which you then could use to send AQL queries or create collections and indices.

    If you want a reproducible state, you could create a set of data that you like maybe by creating a CSV to read using arangoimp, create indices and so on, then dump your database using arangodump and for setting up your SUT use arangorestore.

    There are tools by community members, Migrant Verde and ArangoMiGO that enable you to do schema evolution etc which may be of interest for that purpose too.