Scripts
#
OverviewIf you define the sourceType
property as scripts
you will be able to create a data image whose content will be what you defined in your scripts.
In this case we want to create a PostgreSQL data image whose source is scripts
and is named dev
.
The path given to the scriptsFolder
property is relative to the location of the image definition .yaml
file.
Spawn will execute scripts inside each folder in alphanumeric order.
You can specify multiple scripts folders in the yaml file. Spawn will execute scripts from each folder in the order specified.
#
TutorialIn this tutorial we will create a data image from scripts
and then use it to create a data container. We will then inspect the data container.
Create a file
development.yaml
with your data image specifications.We are defining the source of our data image to be
scripts
and the scripts folders to be imported will be the ones present in the./Database
folder.If we inspect the Database folder we find two
.sql
files:If we inspect the files we get the following:
Run the following command to create a data image.
Create a data container from the newly created data image.
You should now be able to connect to your database and execute queries.
In this example we connect to the PostgreSQL data container (database) using psql.
Notice the created database/data container has a database called
mycompany
as well as the tablecustomers
that where present in our scripts.