Appearance
Connecting a Database
ApiMeld supports PostgreSQL, SQL Server, MySQL/MariaDB, and Oracle as data source types. Database credentials are encrypted at rest and injected into scripts at runtime.
Creating a database data source
- Go to Data Sources → New Data Source
- Select the database type
- Fill in connection details:
- Name — used to reference this data source in scripts (e.g.
ProductionDB) - Host — database server hostname or IP
- Port — default varies by type (PostgreSQL: 5432, SQL Server: 1433, MySQL: 3306, Oracle: 1521)
- Database — database or schema name
- Username / Password — database credentials
- Name — used to reference this data source in scripts (e.g.
- Click Test Connection — ApiMeld attempts a real connection
- Save
Using in scripts
PowerShell:
powershell
# Returns an array of PSObjects — one per row
$users = $datasources.ProductionDB.Query("SELECT id, name, email FROM users WHERE active = 1")
foreach ($user in $users) {
$logger.Info("User: $($user.name) <$($user.email)>")
}JavaScript / TypeScript:
javascript
// Returns an array of plain objects
const users = await datasources.ProductionDB.query(
'SELECT id, name, email FROM users WHERE active = $1',
[true]
)
users.forEach(u => logger.info(`User: ${u.name} <${u.email}>`))Parameterised queries
Always use parameterised queries to prevent SQL injection. The placeholder syntax varies by database:
| Database | Placeholder syntax |
|---|---|
| PostgreSQL | $1, $2, ... |
| SQL Server | @p1, @p2, ... |
| MySQL | ?, ?, ... |
| Oracle | :1, :2, ... |