Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ This extension is tested and known to work with the ODBC drivers of the followin
| Oracle | [odbc_scan_oracle](./test/sql/odbc_scan_oracle.test) | `[ ]` | `[ ]` | `[ ]` | `[ ]` |
| Postgres | [odbc_scan_postgres](./test/sql/odbc_scan_postgres.test) | `[x]` | `[x]` | `[x]` | `[x]` |
| MySQL | [odbc_scan_mysql](./test/sql/odbc_scan_mysql.test) | `[ ]` | `[ ]` | `[ ]` | `[ ]` |
| MariaDB | [odbc_scan_mariadb](./test/sql/odbc_scan_mariadb.test) | `[ ]` | `[ ]` | `[ ]` | `[ ]` |
| MariaDB | [odbc_scan_mariadb](./test/sql/odbc_scan_mariadb.test) | `[x]` | `[x]` | `[x]` | `[x]` |
| Snowflake | [odbc_scan_snowflake](./test/sql/odbc_scan_snowflake.test) | `[ ]` | `[ ]` | `[ ]` | `[ ]` |
| BigQuery | [odbc_scan_big_query](./test/sql/odbc_scan_big_query.test) | `[ ]` | `[ ]` | `[ ]` | `[ ]` |
| MongoDB | [odbc_scan_mongo_db](./test/sql/odbc_scan_mongo_db.test) | `[ ]` | `[ ]` | `[ ]` | `[ ]` |
Expand Down
6 changes: 5 additions & 1 deletion docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,17 @@ services:
mariadb:
image: mariadb:11.0.2
ports:
- "3306:3306"
- "3307:3306"
volumes:
- mariadb_data:/var/lib/mysql
environment:
- MARIADB_USER=mariadb
- MARIADB_PASSWORD=password
- MARIADB_ROOT_PASSWORD=password
# healthcheck:
# test: ["CMD", "mariadb-admin" ,"ping", "-h", "localhost"]
# interval: 1s
# retries: 120

volumes:
db2_data: {}
Expand Down
22 changes: 19 additions & 3 deletions docs/ODBC_CONNECTION_STRING_AND_DSN_FORMATS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ from [connectionstrings.com](https://www.connectionstrings.com).
nix run .#odbc-driver-paths
db2 /nix/store/6flbacf9h5bk09iw37b7sncgjn9mdkwj-db2-odbc-driver-11.5.8/lib/libdb2.so
postgres /nix/store/j648cwmz16prd2n35h0xdhji9b02pip6-postgres-odbc-driver-15.00.0000/lib/psqlodbca.so
mariadb /nix/store/i2i0jj2bxxkq9yc74217b00ddcjnygsg-mariadb-odbc-driver-3.1.9/lib/mariadb/libmaodbc.so
```

## DSN's
Expand All @@ -33,13 +34,22 @@ Driver = postgres
```

```odbcinst.ini
[db2]
Driver = ${DB2_DRIVER_PATH}

[postgres]
Driver = ${POSTGRES_DRIVER_PATH}
```

### MariaDB

```odbc.ini
[mariadb odbc_test]
Driver = mariadb
```

```odbcinst.ini
[mariadb]
Driver = ${MARIADB_DRIVER_PATH}
```

## Connection Strings

### Db2
Expand All @@ -53,3 +63,9 @@ Driver=/nix/store/py6m0q4ij50pwjk6a5f18qhhahrvf2sk-db2-driver-11.5.8/lib/libdb2.
```
Driver=/nix/store/j648cwmz16prd2n35h0xdhji9b02pip6-postgres-odbc-driver-15.00.0000/lib/psqlodbca.so;Server=localhost;Database=odbc_test;Uid=postgres;Pwd=password;Port=5432
```

### MariaDB

```
Driver=/nix/store/i2i0jj2bxxkq9yc74217b00ddcjnygsg-mariadb-odbc-driver-3.1.9/lib/mariadb/libmaodbc.so;Server=localhost;Database=odbc_test;Uid=mysql;Pwd=password;Port=3306
```
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
packages = {
db2-odbc-driver = pkgs.db2-odbc-driver {};
postgres-odbc-driver = pkgs.postgres-odbc-driver {};
mariadb-odbc-driver = pkgs.mariadb-odbc-driver {};
};

# nix run
Expand Down Expand Up @@ -61,6 +62,7 @@
program = toString (pkgs.writeScript "generate-odbcinst-ini" ''
DB2_DRIVER_PATH=${packages.db2-odbc-driver}/lib/${if stdenv.isDarwin then "libdb2.dylib" else "libdb2.so"} \
POSTGRES_DRIVER_PATH=${packages.postgres-odbc-driver}/lib/psqlodbca.so \
MARIADB_DRIVER_PATH=${packages.mariadb-odbc-driver}/lib/mariadb/libmaodbc.so \
envsubst < ./templates/.odbcinst.ini.template > .odbcinst.ini
'');
};
Expand All @@ -69,6 +71,7 @@
program = toString (pkgs.writeScript "ls-odbc-driver-paths" ''
echo "db2 ${packages.db2-odbc-driver}/lib/${if stdenv.isDarwin then "libdb2.dylib" else "libdb2.so"}"
echo "postgres ${packages.postgres-odbc-driver}/lib/psqlodbca.so"
echo "mariadb ${packages.mariadb-odbc-driver}/lib/mariadb/libmaodbc.so"
'');
};
load-db2-schema = {
Expand All @@ -89,6 +92,7 @@
openssl
packages.db2-odbc-driver
packages.postgres-odbc-driver
packages.mariadb-odbc-driver
]
)}:$PATH"
export CC=${stdenv.cc}/bin/clang
Expand All @@ -114,6 +118,7 @@
openssl
packages.db2-odbc-driver
packages.postgres-odbc-driver
packages.mariadb-odbc-driver
]
)}:$PATH"
export CC=${stdenv.cc}/bin/clang
Expand Down Expand Up @@ -148,6 +153,7 @@
pkgs.postgresql_15
packages.db2-odbc-driver
packages.postgres-odbc-driver
packages.mariadb-odbc-driver
];
};
});
Expand Down
3 changes: 3 additions & 0 deletions templates/.odbc.ini.template
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ Driver = db2

[postgres odbc_test]
Driver = postgres

[mariadb odbc_test]
Driver = mariadb
3 changes: 3 additions & 0 deletions templates/.odbcinst.ini.template
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ Driver = ${DB2_DRIVER_PATH}

[postgres]
Driver = ${POSTGRES_DRIVER_PATH}

[mariadb]
Driver = ${MARIADB_DRIVER_PATH}
60 changes: 31 additions & 29 deletions test/sql/odbc_scan_mariadb.test
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
# # name: test/sql/odbc_scan_mariadb.test
# # description: test odbc_scanner extension
# # group: [odbc_scan]
#
# # Before we load the extension, this will fail
# statement error
# SELECT * FROM odbc_scan(
# 'Driver=/opt/homebrew/Cellar/psqlodbc/15.00.0000/lib/psqlodbca.so;Server=localhost;Database=odbc_scanner_duckdb_extension_test;Uid=mariadb;Pwd=password;Port=5432',
# 'db2inst1',
# 'people'
# );
# ----
# Catalog Error: Table Function with name odbc_scan does not exist!
#
# # Require statement will ensure this test is run with this extension loaded
# require odbc_scanner
#
# # Confirm the extension works
# query I
# SELECT * FROM odbc_scan(
# 'Driver=/opt/homebrew/Cellar/psqlodbc/15.00.0000/lib/psqlodbca.so;Server=localhost;Database=odbc_scanner_duckdb_extension_test;Uid=mariadb;Pwd=password;Port=5432',
# 'db2inst1',
# 'people'
# );
# ----
# Lebron James
# Spiderman
# Wonder Woman
# David Bowie
# name: test/sql/odbc_scan_mariadb.test
# description: test odbc_scanner extension
# group: [odbc_scan]

# Before we load the extension, this will fail
statement error
SELECT * FROM odbc_scan(
'DSN={mariadb odbc_test};Server=localhost;Database=odbc_test;Uid=mariadb;Pwd=password;Port=3307',
'',
'people'
)
ORDER BY salary ASC;
----
Catalog Error: Table Function with name odbc_scan does not exist!

# Require statement will ensure this test is run with this extension loaded
require odbc_scanner

# Confirm the extension works
query III
SELECT * FROM odbc_scan(
'DSN={mariadb odbc_test};Server=localhost;Database=odbc_test;Uid=mariadb;Pwd=password;Port=3307',
'',
'people'
)
ORDER BY salary ASC;
----
Lebron James 37 100.1
Spiderman 25 200.2
Wonder Woman 21 300.3
David Bowie 69 400.4
24 changes: 13 additions & 11 deletions test/sql/odbc_scan_mysql.test
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,27 @@
# # Before we load the extension, this will fail
# statement error
# SELECT * FROM odbc_scan(
# 'Driver=/opt/homebrew/Cellar/psqlodbc/15.00.0000/lib/psqlodbca.so;Server=localhost;Database=odbc_scanner_duckdb_extension_test;Uid=mysql;Pwd=password;Port=5432',
# 'db2inst1',
# 'DSN={mysql odbc_test};Server=localhost;Database=odbc_test;Uid=mysql;Pwd=password;Port=3306',
# '',
# 'people'
# );
# )
# ORDER BY salary ASC;
# ----
# Catalog Error: Table Function with name odbc_scan does not exist!
#
# # Require statement will ensure this test is run with this extension loaded
# require odbc_scanner
#
# # Confirm the extension works
# query I
# query III
# SELECT * FROM odbc_scan(
# 'Driver=/opt/homebrew/Cellar/psqlodbc/15.00.0000/lib/psqlodbca.so;Server=localhost;Database=odbc_scanner_duckdb_extension_test;Uid=mysql;Pwd=password;Port=5432',
# 'db2inst1',
# 'DSN={mysql odbc_test};Server=localhost;Database=odbc_test;Uid=mysql;Pwd=password;Port=3306',
# '',
# 'people'
# );
# )
# ORDER BY salary ASC;
# ----
# Lebron James 37 100.10
# Spiderman 25 200.20
# Wonder Woman 21 300.30
# David Bowie 68 400.40
# Lebron James 37 100.1
# Spiderman 25 200.2
# Wonder Woman 21 300.3
# David Bowie 69 400.4