mariadb-connector-odbc-usage

Guides writing and reviewing application code that connects to MariaDB through the ODBC API.

28|115|Updated Jan 28, 2025
One-click install
npx skills add https://github.com/mariadb-corporation/mariadb-docs --skill mariadb-connector-odbc-usage-mariadb-corporation
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: mariadb-connector-odbc-usage
Source: https://github.com/mariadb-corporation/mariadb-docs/tree/main/agent-skills/granular/connectors/mariadb-connector-odbc-usage
Command: npx skills add https://github.com/mariadb-corporation/mariadb-docs --skill mariadb-connector-odbc-usage-mariadb-corporation

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Generated application code that talks to MariaDB through ODBC often contains subtle errors: wrong driver names, named parameter placeholders, incorrect assumptions about prepared statements, autocommit behavior, and TLS activation. This Skill encodes the MariaDB Connector/ODBC-specific behavior so code written or reviewed against it is correct the first time. ## Core Features & Use Cases - Connection string correctness: Covers the DSN-less keyword DRIVER={MariaDB ODBC 3.2 Driver} on Windows and registered driver names or .so paths on Linux/macOS, plus TLS keywords (SSLCA, SSLVERIFY, FORCETLS) that implicitly enable encryption. - API behavior traps: Documents positional ? parameter markers via SQLBindParameter, server-side prepared statements for SQLPrepare+SQLExecute versus client-side SQLExecDirect (unless EDSERVER is set), autocommit ON by default, and the legacy OPTION bitmask. - Use Case: When writing a pyodbc script that bulk-inserts rows into MariaDB, use this Skill to bind parameter arrays with SQL_ATTR_PARAMSET_SIZE, commit explicitly (pyodbc's autocommit defaults to False), and loop SQLMoreResults after stored procedure calls. ## Quick Start Ask the AI to write or review C/C++ or pyodbc code that connects to MariaDB via ODBC, for example: write a pyodbc script that inserts rows into a MariaDB table using bound parameters and explicit commits.

Frequently Asked Questions about mariadb-connector-odbc-usage

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I connect to MariaDB with pyodbc?▼

Connect to MariaDB with pyodbc using a DSN-less string like pyodbc.connect("DRIVER={MariaDB ODBC 3.2 Driver};SERVER=...;DATABASE=...;UID=...;PWD=..."). Note that pyodbc's autocommit defaults to False, so call conn.commit() explicitly after writes.

What is the MariaDB ODBC driver name for connection strings?▼

On Windows the registered name is {MariaDB ODBC 3.2 Driver}, with the version number changing per release series. On Linux and macOS, Driver= is either a path to libmaodbc.so or the name registered in odbcinst.ini via odbcinst -i -d.

Does MariaDB Connector/ODBC support named parameters?▼

No, ODBC only supports positional ? parameter markers bound in order with SQLBindParameter, or passed positionally through a wrapper like pyodbc's cursor.execute(sql, params). Named or :name placeholders are not supported.

Why does my ODBC transaction commit immediately against MariaDB?▼

Autocommit is ON by default because the connector sends SET autocommit=1 at connect time, matching the ODBC standard. Turn it off with SQLSetConnectAttr(dbc, SQL_ATTR_AUTOCOMMIT, SQL_AUTOCOMMIT_OFF, 0) and then use SQLEndTran with SQL_COMMIT or SQL_ROLLBACK.

Does SQLExecDirect use server-side prepared statements in MariaDB ODBC?▼

No, SQLExecDirect defaults to client-side prepare with the text protocol. Set the EDSERVER connection-string option (since 3.2.5) or SQL_ATTR_EXECDIRECT_ON_SERVER to force server-side prepare, while SQLPrepare plus SQLExecute uses server-side prepared statements by default.

How do I enable TLS in a MariaDB ODBC connection string?▼

Setting any of SSLCA, SSLCERT, SSLKEY, SSLCIPHER, or SSLCAPATH automatically enables TLS enforcement with no separate switch. Use FORCETLS=1 to require TLS without certificate material, and SSLVERIFY=1 to verify the server certificate against SSLCA.