Registry / database / databricks-sql-connector-core

databricks-sql-connector-core

JSON →
library4.0.1pypypi✓ verified 90d ago

The core library for connecting Python to Databricks SQL, providing a DB-API 2.0 interface. Currently at version 4.2.6, released frequently (multiple releases per month). Supports Python 3.8 to 3.14. Built on Thrift and Arrow for efficient data transfer.

pip install databricks-sql-connector-core
INSTALL
IMPORT
SIG · DATABRICKS-SQL-CON
D
databricks-sql-connector-core
databasepythonv4.0.1
Install
11.3s avg
Import
35ms
Disk
334MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v4.0.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.910 runs
build_error
glibc
py 3.10–3.910 runs
installs and imports cleanly · install 11.3s · import 0.035s · 330MB
334MB installed
● package 334MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

connect
✓ from databricks import sql
✗ from databricks_sql_connector_core import connect
The main package is 'databricks.sql', not the internal core module.

Connect to Databricks SQL with personal access token and run a query.

import os from databricks import sql connection = sql.connect( server_hostname=os.environ.get('DATABRICKS_SERVER_HOSTNAME', ''), http_path=os.environ.get('DATABRICKS_HTTP_PATH', ''), access_token=os.environ.get('DATABRICKS_TOKEN', ''), ) with connection.cursor() as cursor: cursor.execute("SELECT 1 as col") result = cursor.fetchall() print(result) connection.close()
Debug
Known issues
breakingThrift dependency upgrade in 4.x: The library switched from thrift 0.16.0 to 0.19.0. Code that directly imports thrift or uses custom thrift transports may break.
fix
Update any custom thrift code to be compatible with thrift 0.19.0. If you encounter 'thrift.protocol.TProtocolException', check your thrift version.
affects: >=4.0.0
deprecatedfetchall_arrow() and fetchmany_arrow() are deprecated in favor of fetchall() and fetchmany() which return Arrow-backed results by default in v4.
fix
Replace cursor.fetchall_arrow() with cursor.fetchall(). The returned type is now pyarrow.Table.
affects: >=4.0.0
gotchaConnection string format: 'databricks-sql-connector-core' does not support connection strings like 'databricks+pyodbc://...'. Use the programmatic connect() method with server_hostname, http_path, and access_token.
fix
Do not use SQLAlchemy connection strings directly; use databricks-sql-connector with SQLAlchemy dialect for that.
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'databricks'
Installed 'databricks-sql-connector-core' but importing incorrectly such as 'import databricks_sql_connector_core'.
fix
Install the package and use 'from databricks import sql'.
pyarrow.lib.ArrowTypeError: Expected a string or bytes, got a 'NoneType'
Passing None for server_hostname or http_path in connect().
fix
Set environment variables or pass non-None strings: server_hostname='abc.cloud.databricks.com', http_path='/sql/1.0/warehouses/...'.
thrift.transport.TTransport.TTransportException: Could not connect to...
Invalid server_hostname or network connectivity issue, or wrong port (default 443 but custom allowed).
fix
Verify server_hostname is correct (e.g., 'adb-...azuredatabricks.net') and that your network can reach the Databricks workspace. Check firewall/proxy settings.
Upgrade
Version history
4.0.1latest on PyPI · released Oct 10, 2024
Audit
Dependencies
pandasoptionalOptional for DataFrame result sets; required for fetchall_arrow() with pandas integration
sqlalchemyoptionalOptional for SQLAlchemy dialect support
Agent activity
23 hits · last 30 days
node
22
OpenAI (training)
1
Resources