svyDataSeed

Use svyDataSeed in Servoy Cloud to export database tables to CSV seed files and import them into any environment for bootstrapping, testing, or reference data setup.

The svyDataSeed scope helps you move data between environments by exporting database tables to CSV files and importing them back. This is useful for:

  • Bootstrapping a new cloud environment with reference data

  • Setting up test environments with a known dataset

  • Sharing a consistent data state across multiple developers

Seed files are stored as media files in your Servoy solution under medias/dataseeds/. Each database gets its own zip file containing one CSV per table.

Exporting database tables to seed files

createDataSeedFiles()

Exports all tables from a selected database. A dialog appears asking which database to export.

scopes.svyDataSeed.createDataSeedFiles();

Optional parameters let you customize the export behavior:

Parameter
Type
Default
Description

customPathToSvyCloudUtils

String

Custom output path instead of the workspace

returnDataseedFile

Boolean

true in cloud

When true, returns the zip file instead of writing to workspace

runFullTableRecalc

Boolean

false

Recalculates stored calcs before export (slow on large datasets)

noZip

Boolean

false

Exports as plain CSV folder instead of a zip

excludeTableNames

Array<String>

['temp_%']

Table names to skip; supports % as a wildcard

columnNameRegex

RegExp

Skip special character checks on matching column names

createDataSeedFile(selectedDB, ...)

Exports a specific database by name. Use this when you don't want the dialog, or when running in an automated context.

Has the same optional parameters as createDataSeedFiles(), plus:

Parameter
Type
Description

additionalFilters

Array<{fieldName, value, required?}>

Filter rows by column value. Set required: true to skip tables that don't have the column

limitTableCount

Number

Maximum rows per table — useful for generating sample data

Importing seed files into a database

runDataseedFromMedia()

Imports all seed files found in the solution's media library. Run this during deployment or environment initialization.

Parameter
Type
Default
Description

clearTablesNotInSeed

Boolean

false

Truncate tables that have no corresponding seed file

dataseedFile

Array<JSFile or JSMedia>

Import specific files instead of all media seeds

dbNameToImport

String

Required when dataseedFile is set — specifies which database to import into

executeInTransaction

Boolean

false

Wrap the import in a single database transaction

deleteExistingData

Boolean

true

Truncate existing table data before import

statusCallBackFunction

Function

Callback called with (status, tableName, current, total) during import

The status callback receives these values for status:

  • 'started' — table import is beginning

  • 'running' — rows are being inserted

  • 'done' — table import is complete

getExistingDataseeds()

Returns an array of DataseedFile objects for all seed files currently in the solution's media library.

How seed files are structured

Each exported database becomes a zip file (or folder when noZip is true) containing one CSV file per table. The CSV uses comma delimiters and double-quote text qualifiers.

  • Datetime columns are exported in UTC and re-converted on import

  • Binary (media) columns are base64-encoded

  • Tables prefixed with temp_ are excluded by default

  • Metadata tables and i18n tables are skipped automatically

Large tables are split into multiple CSV files (named tablename#2.csv, tablename#3.csv, etc.) when they exceed 200 MB.

circle-info

When importing, all existing data is truncated before inserting seed rows. Set deleteExistingData: false if you want to add rows without clearing first.


See also: svyCloud for environment detection and tenant session management, and svyDeployUtils for running database migrations alongside your seed import.

Last updated

Was this helpful?