Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: Add multi-statement transaction support#704

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
jayantsing-db wants to merge2 commits intomain
base:main
Choose a base branch
Loading
frommst-pysql
Open
Show file tree
Hide file tree
Changes fromall 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 deletionsREADME.md
View file
Open in desktop
Original file line numberDiff line numberDiff 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

[8]ページ先頭

©2009-2025 Movatter.jp