Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreateTableOptions ¶
type CreateTableOptions struct {
// View specifies whether the created table is a view.
View bool
// If BeforeCreateFn is set, it will be executed before the create query is executed.
BeforeCreateFn func(ctx context.Context, conn *sqlx.Conn) error
// If AfterCreateFn is set, it will be executed after the create query is executed.
// This will execute even if the create query fails.
AfterCreateFn func(ctx context.Context, conn *sqlx.Conn) error
}
type DB ¶
type DB interface {
// Close closes the database.
Close() error
// AcquireReadConnection returns a connection to the database for reading.
// Once done the connection should be released by calling the release function.
// This connection must only be used for select queries or for creating and working with temporary tables.
AcquireReadConnection(ctx context.Context) (conn *sqlx.Conn, release func() error, err error)
// Size returns the size of the database in bytes.
// It is currently implemented as sum of the size of all serving `.db` files.
Size() int64
// CreateTableAsSelect creates a new table by name from the results of the given SQL query.
CreateTableAsSelect(ctx context.Context, name string, sql string, opts *CreateTableOptions) error
// MutateTable allows mutating a table in the database by calling the mutateFn.
MutateTable(ctx context.Context, name string, mutateFn func(ctx context.Context, conn *sqlx.Conn) error) error
// DropTable removes a table from the database.
DropTable(ctx context.Context, name string) error
// RenameTable renames a table in the database.
RenameTable(ctx context.Context, oldName, newName string) error
}
type DBOptions ¶
type DBOptions struct {
// LocalPath is the path where local db files will be stored. Should be unique for each database.
LocalPath string
// Remote is the blob storage bucket where the database files will be stored. This is the source of truth.
// The local db will be eventually synced with the remote.
Remote *blob.Bucket
// ReadSettings are settings applied the read duckDB handle.
ReadSettings map[string]string
// WriteSettings are settings applied the write duckDB handle.
WriteSettings map[string]string
// InitQueries are the queries to run when the database is first created.
InitQueries []string
Logger *slog.Logger
OtelAttributes []attribute.KeyValue
}
func (*DBOptions) ValidateSettings ¶
Click to show internal directories.
Click to hide internal directories.