Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Open ¶
Open opens a database specified by its database driver name and a driver-specific data source name. And returns a new database handle with logger.
Example ¶
package main
import (
"context"
"log/slog"
"os"
sqlslog "github.com/akm/sql-slog"
)
func main() {
dsn := "file::memory:?cache=shared"
ctx := context.TODO()
logger := slog.New(slog.NewJSONHandler(os.Stdout, nil))
db, err := sqlslog.Open(ctx, "sqlite3", dsn, logger)
if err != nil {
// Handle error
}
defer db.Close()
// Use db as a regular *sql.DB
}
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.