db

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: May 26, 2023 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package db manages the DB part of the kjudge package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Rollback

func Rollback(tx *sqlx.Tx)

Rollback performs a rollback on the transaction. Logs the error down on error.

Types

type DB

type DB struct {
	*sqlx.DB

	PersistentConn *sqlite3.SQLiteConn
}

DB is an implementation of the underlying DB.

func New

func New(filename string) (*DB, error)

New creates a new DB object from the given filename.

func (*DB) Close added in v0.7.5

func (db *DB) Close() error

Close attempts to close the database.

type DBContext

type DBContext interface {
	// Get binds a single row into a struct.
	Get(result interface{}, query string, args ...interface{}) error
	// Select binds rows into an array of structs.
	Select(results interface{}, query string, args ...interface{}) error
	// Exec executes a query.
	Exec(query string, args ...interface{}) (sql.Result, error)
}

DBContext defines a slim common interface between Db and Tx.

Jump to

Keyboard shortcuts

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