Skip to content
Open
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
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,37 @@ or to a Databricks Runtime interactive cluster (e.g. /sql/protocolv1/o/123456789
> to authenticate the target Databricks user account and needs to open the browser for authentication. So it
> can only run on the user's machine.

## Transaction Support

The connector supports multi-statement transactions with manual commit/rollback control:

```python
import os
from databricks import sql

connection = sql.connect(
server_hostname=os.getenv("DATABRICKS_HOST"),
http_path=os.getenv("DATABRICKS_HTTP_PATH")
)

# Disable autocommit to use explicit transactions
connection.autocommit = False

cursor = connection.cursor()
try:
cursor.execute("INSERT INTO table1 VALUES (1, 'a')")
cursor.execute("INSERT INTO table2 VALUES (2, 'b')")
connection.commit() # Commit both inserts atomically
except Exception as e:
connection.rollback() # Rollback on error
raise

cursor.close()
connection.close()
```

For detailed information about transaction behavior, isolation levels, error handling, and best practices, see [TRANSACTIONS.md](TRANSACTIONS.md).

## SQLAlchemy
Starting from `databricks-sql-connector` version 4.0.0 SQLAlchemy support has been extracted to a new library `databricks-sqlalchemy`.

Expand Down
Loading
Loading