Skip to content

Commit c58e6c7

Browse files
committed
Update docker-compose and README for ODBC support; enhance CI workflow to include ODBC testing
1 parent 7dcb369 commit c58e6c7

File tree

4 files changed

+73
-6
lines changed

4 files changed

+73
-6
lines changed

.github/workflows/ci.yml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,20 @@ jobs:
4646
runs-on: ubuntu-latest
4747
strategy:
4848
matrix:
49-
database: ["postgres", "mysql", "mssql"]
49+
include:
50+
- database: postgres
51+
container: postgres
52+
db_url: "postgres://root:[email protected]/sqlpage"
53+
- database: mysql
54+
container: mysql
55+
db_url: "mysql://root:[email protected]/sqlpage"
56+
- database: mssql
57+
container: mssql
58+
db_url: "mssql://root:[email protected]/sqlpage"
59+
- database: odbc
60+
container: postgres
61+
db_url: "Driver={PostgreSQL};Server=127.0.0.1;Port=5432;Database=sqlpage;UID=root;PWD=Password123!"
62+
setup_odbc: true
5063
steps:
5164
- uses: actions/checkout@v4
5265
- name: Set up cargo cache
@@ -55,16 +68,21 @@ jobs:
5568
run: |
5669
sudo apt-get update
5770
sudo apt-get install -y unixodbc-dev freetds-dev
71+
- name: Setup ODBC for testing
72+
if: matrix.setup_odbc
73+
run: |
74+
# Install PostgreSQL ODBC driver (automatically registers the driver)
75+
sudo apt-get install -y odbc-postgresql
5876
- name: Start database container
59-
run: docker compose up --wait ${{ matrix.database }}
77+
run: docker compose up --wait ${{ matrix.container }}
6078
- name: Show container logs
6179
if: failure()
62-
run: docker compose logs ${{ matrix.database }}
80+
run: docker compose logs ${{ matrix.container }}
6381
- name: Run tests against ${{ matrix.database }}
6482
timeout-minutes: 5
6583
run: cargo test
6684
env:
67-
DATABASE_URL: ${{ matrix.database }}://root:[email protected]/sqlpage
85+
DATABASE_URL: ${{ matrix.db_url }}
6886
RUST_BACKTRACE: 1
6987
RUST_LOG: sqlpage=debug
7088

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ select
128128
- [PostgreSQL](https://www.postgresql.org/), and other compatible databases such as *YugabyteDB*, *CockroachDB* and *Aurora*.
129129
- [MySQL](https://www.mysql.com/), and other compatible databases such as *MariaDB* and *TiDB*.
130130
- [Microsoft SQL Server](https://www.microsoft.com/en-us/sql-server), and all compatible databases and providers such as *Azure SQL* and *Amazon RDS*.
131+
- **ODBC-compatible databases** such as *Oracle*, *Snowflake*, *BigQuery*, *IBM DB2*, and many others through ODBC drivers.
131132

132133
## Get started
133134

@@ -175,6 +176,34 @@ An alternative for Mac OS users is to use [SQLPage's homebrew package](https://f
175176
- In a terminal, run the following commands:
176177
- `brew install sqlpage`
177178
179+
180+
### ODBC Setup
181+
182+
You can skip this section if you want to use one of the built-in database drivers (SQLite, PostgreSQL, MySQL, Microsoft SQL Server).
183+
184+
SQLPage supports ODBC connections to connect to databases that don't have native drivers, such as Oracle, Snowflake, BigQuery, IBM DB2, and many others.
185+
186+
ODBC support requires an ODBC driver manager and appropriate database drivers to be installed on your system.
187+
188+
#### Install ODBC
189+
190+
- On windows, it's installed by default.
191+
- On linux: `sudo apt-get install -y unixodbc odbcinst unixodbc-common libodbcinst2`
192+
- On mac: `brew install unixodbc`
193+
194+
195+
#### Install your ODBC database driver
196+
- [DuckDB](https://duckdb.org/docs/stable/clients/odbc/overview.html)
197+
- [Snowflake](https://docs.snowflake.com/en/developer-guide/odbc/odbc)
198+
- [BigQuery](https://cloud.google.com/bigquery/docs/reference/odbc-jdbc-drivers)
199+
- For other databases, follow your database's official odbc install instructions.
200+
201+
#### Connect to your database
202+
203+
- Find your connection string. You can use https://www.connectionstrings.com/
204+
- Use it in the [DATABASE_URL configuration option](./configuration.md)
205+
206+
178207
## How it works
179208

180209
![architecture diagram](./docs/architecture-detailed.png)

configuration.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ If you have a `.env` file in the current directory or in any of its parent direc
6666

6767
The `database_url` parameter sets all the connection parameters for the database, including
6868

69-
- the database engine type (`sqlite`, `postgres`, `mysql`, `mssql`, etc.)
69+
- the database engine type (`sqlite`, `postgres`, `mysql`, `mssql`, or ODBC connection strings)
7070
- the username and password
7171
- the host (or ip adress) and port
7272
- the database name
@@ -87,6 +87,26 @@ A full connection string for a PostgreSQL database might look like this:
8787
postgres://my_user:p%40ss@localhost:5432/my_database?sslmode=verify-ca&sslrootcert=/path/to/ca.pem&sslcert=/path/to/cert.pem&sslkey=/path/to/key.pem&application_name=my_application
8888
```
8989

90+
#### ODBC Connection Strings
91+
92+
For ODBC-compatible databases (Oracle, Snowflake, BigQuery, IBM DB2, etc.), you can use ODBC connection strings directly:
93+
94+
```bash
95+
# Using a Data Source Name (DSN)
96+
DATABASE_URL="DSN=MyDatabase"
97+
98+
# Using inline connection parameters
99+
DATABASE_URL="Driver={PostgreSQL};Server=localhost;Port=5432;Database=mydb;UID=myuser;PWD=mypassword"
100+
101+
# Oracle example
102+
DATABASE_URL="Driver={Oracle ODBC Driver};Server=localhost:1521/XE;UID=hr;PWD=password"
103+
104+
# Snowflake example
105+
DATABASE_URL="Driver={SnowflakeDSIIDriver};Server=account.snowflakecomputing.com;Database=mydb;UID=user;PWD=password"
106+
```
107+
108+
ODBC drivers must be installed and configured on your system. On Linux, you typically need `unixodbc` and the appropriate database-specific ODBC driver.
109+
90110
If the `database_password` configuration parameter is set, it will override any password specified in the `database_url`.
91111
It does not need to be percent-encoded.
92112
This allows you to keep the password separate from the connection string, which can be useful for security purposes, especially when storing configurations in version control systems.

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@ services:
5959
image: mariadb
6060
environment:
6161
MYSQL_ROOT_PASSWORD: Password123!
62-
MYSQL_DATABASE: sqlpage
62+
MYSQL_DATABASE: sqlpage

0 commit comments

Comments
 (0)