Skip to main content
Model tells Syncmaven how to access the data in the database. Typically, it’s represented by a SQL query along with parameters. The query is executed by Syncmaven to fetch the data from the database. Models are defined in the ./models directory of the project.

SQL file

Model can be defined in a SQL file. The file should have a .sql extension. The file should contain a SQL query
In addition to the SQL query, the file can set model configuration using the config directive
Please note that the config directive should be in a comment block to be ignored by the SQL parser. The model must define datasource, which is the connection string to the database. Also, the model have two optional parameters name and id. Default values for these parameters is the file name without the extension.

YAML file

Model can also be defined in a YAML file. The file should have a .yaml or .ym; extension:
As in the SQL file, the YAML file must define datasource and query. name and id are optional parameters.

Datasource

Postgres

To connect to a Postgres database, the datasource should be a connection string: postgres://user:password@host:port/dbname