txnsql

package module
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Copyright 2024 The txnsql Authors

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package txnsql provides a transaction adapter for SQL databases, seamlessly integrating with the txn package to enable distributed transaction management across multiple data sources.

Key Features:

  • Transactional Support: Leverages SQL database transaction capabilities to ensure atomicity of operations.
  • Seamless Integration: Easily integrates with the txn package for managing transactions across different databases.
  • Convenient API: Provides a simple interface (SqlAdapter) for interacting with SQL databases within a transaction.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SqlAdapter

type SqlAdapter interface {
	txn.Adapter

	// Returns current transaction if it exists.
	GetCurrent() SqlDbTx
}

SqlAdapter is the interface for interacting with SQL databases within a transaction. It extends the txn.Adapter interface to provide additional SQL-specific functionality.

func New

func New(db *sql.DB) SqlAdapter

New creates a new SqlAdapter instance using the provided *sql.DB.

type SqlDbTx added in v1.0.3

type SqlDbTx interface {
	PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)
	Prepare(query string) (*sql.Stmt, error)
	ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
	Exec(query string, args ...any) (sql.Result, error)
	QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
	Query(query string, args ...any) (*sql.Rows, error)
	QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
	QueryRow(query string, args ...any) *sql.Row
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL