diff --git a/README.md b/README.md index 09efd71..2b40fb7 100644 --- a/README.md +++ b/README.md @@ -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) | `[ ]` | `[ ]` | `[ ]` | `[ ]` | diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 50eea88..ef8c097 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -74,17 +74,22 @@ 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: {} mssql_data: {} oracle_data: {} postgres_data: {} + mysql_data: {} mariadb_data: {} diff --git a/docs/ODBC_CONNECTION_STRING_AND_DSN_FORMATS.md b/docs/ODBC_CONNECTION_STRING_AND_DSN_FORMATS.md index d813f6d..7fc2ddf 100644 --- a/docs/ODBC_CONNECTION_STRING_AND_DSN_FORMATS.md +++ b/docs/ODBC_CONNECTION_STRING_AND_DSN_FORMATS.md @@ -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/j648cwmz16prd2n35h0xdhji9b02pip6-postgres-odbc-driver-15.00.0000/lib/psqlodbca.so ``` ## DSN's @@ -33,13 +34,22 @@ Driver = postgres ``` ```odbcinst.ini -[db2] -Driver = ${DB2_DRIVER_PATH} - [postgres] Driver = ${POSTGRES_DRIVER_PATH} ``` +### MySQL + +```odbc.ini +[mariadb odbc_test] +Driver = mariadb +``` + +```odbcinst.ini +[mariadb] +Driver = ${MARIADB_DRIVER_PATH} +``` + ## Connection Strings ### Db2 @@ -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/j648cwmz16prd2n35h0xdhji9b02pip6-postgres-odbc-driver-15.00.0000/lib/psqlodbca.so;Server=localhost;Database=odbc_test;Uid=mysql;Pwd=password;Port=3306 +``` diff --git a/flake.lock b/flake.lock index 980bc5e..f370b86 100644 --- a/flake.lock +++ b/flake.lock @@ -74,11 +74,11 @@ "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1689550386, - "narHash": "sha256-YLbm7bt2mUeYoYCyTBhvjHmO+W+MT+GzCBP+vZA6d00=", + "lastModified": 1689914298, + "narHash": "sha256-TcY/8u+5EPsTBXaQPpvZJh+wVAmOUkBZjk6w/c4dgTY=", "owner": "rupurt", "repo": "odbc-drivers-nix", - "rev": "85f352b51bbaaa0376333f5449b27f41ee7b8150", + "rev": "7b2a8bcde95972d352c864eef7dfbeb7f21d2ccd", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index bca203e..e45fc15 100644 --- a/flake.nix +++ b/flake.nix @@ -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 @@ -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 ''); }; @@ -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 = { @@ -89,6 +92,7 @@ openssl packages.db2-odbc-driver packages.postgres-odbc-driver + packages.mariadb-odbc-driver ] )}:$PATH" export CC=${stdenv.cc}/bin/clang @@ -114,6 +118,7 @@ openssl packages.db2-odbc-driver packages.postgres-odbc-driver + packages.mariadb-odbc-driver ] )}:$PATH" export CC=${stdenv.cc}/bin/clang @@ -148,6 +153,7 @@ pkgs.postgresql_15 packages.db2-odbc-driver packages.postgres-odbc-driver + packages.mariadb-odbc-driver ]; }; }); diff --git a/templates/.odbc.ini.template b/templates/.odbc.ini.template index 1eba606..0a45c6f 100644 --- a/templates/.odbc.ini.template +++ b/templates/.odbc.ini.template @@ -3,3 +3,6 @@ Driver = db2 [postgres odbc_test] Driver = postgres + +[mariadb odbc_test] +Driver = mariadb diff --git a/templates/.odbcinst.ini.template b/templates/.odbcinst.ini.template index db361d9..374254a 100644 --- a/templates/.odbcinst.ini.template +++ b/templates/.odbcinst.ini.template @@ -3,3 +3,6 @@ Driver = ${DB2_DRIVER_PATH} [postgres] Driver = ${POSTGRES_DRIVER_PATH} + +[mariadb] +Driver = ${MARIADB_DRIVER_PATH} diff --git a/test/sql/odbc_scan_mariadb.test b/test/sql/odbc_scan_mariadb.test index 7e07a1c..23c51c1 100644 --- a/test/sql/odbc_scan_mariadb.test +++ b/test/sql/odbc_scan_mariadb.test @@ -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 diff --git a/test/sql/odbc_scan_mysql.test b/test/sql/odbc_scan_mysql.test index 5f0c8ec..f133903 100644 --- a/test/sql/odbc_scan_mysql.test +++ b/test/sql/odbc_scan_mysql.test @@ -5,10 +5,11 @@ # # 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! # @@ -16,14 +17,15 @@ # 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