# Database plugin
Executes SQL queries against configured databases and stores results as JSON in SharePoint lists. Enables scheduled database synchronization and integration with external database systems.
DLL: Epona.Database.dll
# What it does
- Query execution — runs SQL queries against configured databases
- Result storage — saves query results as JSON in SharePoint lists
- Scheduled execution — runs queries on configurable intervals
- Credential management — encrypts and securely manages database passwords
- Multiple sources — supports multiple database connections and queries per configuration
- Version tracking — stores last-modified timestamps for incremental synchronization
# Prerequisites
- Network connectivity to target database server
- Database credentials with execute permissions
- SQL Server, Oracle, or other ADO.NET supported database
- Target SharePoint list to store query results
# Configuration
# Database job settings
# Name
Type: string | Required: Yes
Unique name for this database job
# Disabled
Type: boolean | Required: No
Disable this job without removing configuration
# ConnectionString
Type: string | Required: Yes
Database connection string (host, port, database)
# Password
Type: string | Required: No
Database password (encrypted; extracted automatically from connection string)
# ConnectionStringProviderName
Type: string | Required: Yes
Database provider (e.g., System.Data.SqlClient, Oracle.ManagedDataAccess.Client)
# ConnectionStringProviderNameFactory
Type: string | Required: No
Override factory type name for custom database provider instantiation
# Query settings
# CommandText
Type: string | Required: Yes
SQL query to execute, or path to .sql file relative to provisioning service bin directory
# CommandTimeout
Type: int | Required: No
Query timeout in seconds (default: 30)
# Execution schedule
# IntervalInMinutes
Type: int | Default: — | Required: No
Execution interval in minutes
# StartTime
Type: TimeSpan | Default: — | Required: No
Optional: earliest time of day to run (e.g., 09:00:00)
# EndTime
Type: TimeSpan | Default: — | Required: No
Optional: latest time of day to run (e.g., 17:00:00)
# UseUTCDateTime
Type: boolean | Default: false | Required: No
Use UTC time (true) or local time (false)
# LastRunDateTime
Type: DateTime | Default: — | Required: No
Timestamp of last successful execution (read-only)
# Testing mode
# TestMapping
Type: boolean | Default: false | Required: No
Store result in test directory instead of production; does not update LastRunDateTime
# Query parameters
# Last-run date parameter
Queries can reference @LastRunDateTime to fetch only new or changed records:
SELECT * FROM Contacts WHERE ModifiedDate > @LastRunDateTime
The parameter is automatically set to the LastRunDateTime of the previous successful execution.
# SQL file references
Instead of embedding SQL in the configuration, reference a file path:
CommandText: queries/customer-sync.sql
The provisioning service looks for the file relative to its bin directory.
# Example configuration
| Property | Example value |
|---|---|
Jobs[0].Name | DailyCustomerSync |
Jobs[0].ConnectionString | Server=sqlserver.example.com;Database=SourceDB |
Jobs[0].Password | p@ssw0rd |
Jobs[0].ConnectionStringProviderName | System.Data.SqlClient |
Jobs[0].CommandText | SELECT CustomerCode, CustomerName, ModifiedDate FROM Customers WHERE ModifiedDate > @LastRunDateTime |
Jobs[0].CommandTimeout | 60 |
Jobs[0].IntervalInMinutes | 1440 |
Jobs[0].StartTime | 08:00:00 |
Jobs[0].EndTime | 18:00:00 |
# Scheduling behavior
The Database plugin schedules execution based on interval and time-of-day constraints:
- Interval: job runs every N minutes
- StartTime: job only runs after this time of day (optional)
- EndTime: job only runs before this time of day (optional)
- Example: with interval=60, StartTime=09:00, EndTime=17:00, the job runs hourly during business hours
# Security
Database passwords are encrypted using the provisioning service's encryption key:
- Password entered in configuration UI is automatically extracted from connection string
- Password is encrypted with the service account key
- Encrypted password is stored in configuration file
- At runtime, password is decrypted before opening connection
# Multiple jobs per configuration
A single Database configuration can contain multiple jobs:
{
"Jobs": [
{ "Name": "Job1", ... },
{ "Name": "Job2", ... },
{ "Name": "Job3", ... }
]
}
Each job runs on its own schedule independently.
# Troubleshooting
# Common issues
| Issue | Cause | Resolution |
|---|---|---|
| Cannot connect | Invalid connection string or credentials | Verify connection string syntax, server name, and password |
| Query timeout | Query too slow for configured timeout | Increase CommandTimeout or optimize SQL query |
| @LastRunDateTime not working | Parameter name misspelled or case mismatch | Use exact parameter name @LastRunDateTime (case-sensitive) |
| File not found | SQL file path incorrect | Verify relative path from provisioning service bin directory |
| Password not persisting | Password contains semicolon | Enclose password in quotation marks: Password="p@ss;word" |
# Related
- Configuration reference — provisioning configuration reference
- Plugins index — list of available plugins