ODBC
Connect & Extract data from databases via Open Database Connectivity (ODBC)
Open Database Connectivity (ODBC) provides a standardized interface for accessing various databases using ODBC drivers. This connector enables data extraction from databases that may not have a dedicated Sling connector, or when ODBC is the preferred access method. This is available starting v1.5.3.
Setup
Before using ODBC connections, ensure you have the appropriate ODBC driver installed for your database:
macOS (via Homebrew):
# SQL Server
brew install microsoft/mssql-release/msodbcsql18
# PostgreSQL
brew install psqlodbc
# MySQL
brew install mysql-connector-odbcLinux (Debian/Ubuntu):
# SQL Server
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
sudo add-apt-repository "$(curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list)"
sudo apt-get update
sudo apt-get install msodbcsql18
# PostgreSQL
sudo apt-get install odbc-postgresql
# MySQL
sudo apt-get install libmyodbcWindows: Download and install the appropriate ODBC driver from the vendor's website.
Connection Properties
conn_string(required) -> The ODBC connection string (DSN or DSN-less format)conn_template(optional) -> Specify the SQL template name to use for query syntax. This should be the name of a template (e.g.,sqlserver,postgres,mysql,db2,sap_hana). If not provided, Sling auto-detects from the connection string.
Custom Templates for Unsupported Drivers
For ODBC drivers that connect to databases not natively supported by Sling (e.g., DB2, SAP HANA, Teradata), you can create your own custom template:
Create a template file at
~/.sling/templates/{template_name}.yaml(e.g.,~/.sling/templates/db2.yaml)Define the SQL syntax and type mappings specific to your database (see Template Overrides for the template structure)
Reference the template name in your connection's
conn_templateproperty
For example, to connect to DB2 via ODBC:
Then reference it in your connection:
Using sling conns
sling connsEnvironment Variable
Sling Env File YAML
See here to learn more about the sling env.yaml file.
Replication Example
Here's an example replication configuration to extract data from an ODBC source to PostgreSQL:
Connection String Formats
DSN (Data Source Name)
Use a pre-configured DSN from your ODBC configuration:
DSN-less (Driver-based)
Connect directly without a DSN:
SQL Server:
PostgreSQL:
MySQL:
Troubleshooting
Driver Not Found
If you receive a "driver not found" error, verify that:
The ODBC driver is installed
The driver name in your connection string matches exactly (including brackets and version)
On Linux/macOS, check
/etc/odbcinst.inifor installed drivers
SQL Syntax Errors
If you encounter SQL syntax errors (e.g., LIMIT vs TOP), ensure:
The driver type is being correctly auto-detected from your connection string
Or explicitly set
conn_templateto match your database type
Connection Timeout
For slow connections, you may need to add timeout parameters to your connection string:
If you are facing issues connecting, please reach out to us at [email protected], on discord or open a Github Issue here.
Last updated
Was this helpful?