1. Home
  2. Docs
  3. Getting started
  4. Setup a workflow

Setup a workflow

1. Create a new workflow folder #

First define a project name. This can be a customer name or an internal project name. Please replace the placeholder [projectName] below with your project name.

mkdir -p workflows/[projectName]/models

Let’s say, you need to create a workflow for your customer mycustomer:

mkdir -p workflows/mycustomer/models

2. Add an authentication file #

Next you have to create an authentication file for this workflow.

cd workflows/mycustomer
touch dbauth.yml

Now add following content to the just generated file:

type: "pgsql"
host: "localhost"
port: "5432"
user: "db_mycustomer"
pass: "iegKyPFhxUHVh/7ka9HxH3Pdd3jD2JkJoePRRfnuopzlsd8R5p97z4jzuwckDl=="
db: "mycustomer"

As you will check in the dbauth.yml into git, the password has to be encrypted:

lesql encrypt [database_password]

Copy the encrypted password to pass: of your dbauth.yml

As every json is a valid yaml 1.2, the dbauth.yml file can be a json file as well:

{
  "type": "pgsql",
  "host": "localhost",
  "port": "5432",
  "user": "db_mycustomer",
  "pass": "iegKyPFhxUHVh/7ka9HxH3Pdd3jD2JkJoePRRfnuopzlsd8R5p97z4jzuwckDl==",
  "db": "mycustomer"
}

3. Create model #

Now create your model files in the new created workflows/mycustomer/models folder.

cd workflows/mycustomer/models
touch 000001-table2.le.sql

Add a base structure of a le.sql file into this file e.g.:

{{ block "CONFIG" .}}
{{end}}

{{ block "SELECT" .}}
SELECT
  "abc"
FROM
  {{ .Project }}.{{ ref "table1" }}
WHERE
  "date" BETWEEN '{{ .StartDate }}' and '{{ .EndDate }}'
{{end}}

Now it is time to work on your model.

4. Create further models #

Repeat step 3) for every model you need to create