database

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BulkInsertOptions

type BulkInsertOptions struct {
	// BatchSize determines how many rows to insert per transaction
	BatchSize int

	// MaxRetries sets the maximum number of retry attempts for failed operations
	MaxRetries int

	// MaxJunctionTableArraySize limits the maximum array size for junction table creation
	MaxJunctionTableArraySize int

	// ArrayWarningThreshold sets the threshold for logging warnings about large arrays
	ArrayWarningThreshold int
}

BulkInsertOptions configures bulk insertion behavior

func DefaultBulkInsertOptions

func DefaultBulkInsertOptions() *BulkInsertOptions

DefaultBulkInsertOptions returns sensible defaults for bulk insertion

type BulkInserter

type BulkInserter struct {
	// contains filtered or unexported fields
}

BulkInserter handles efficient batch insertion of DAT file data

func NewBulkInserter

func NewBulkInserter(db *Database, options *BulkInsertOptions) *BulkInserter

NewBulkInserter creates a new bulk inserter with the given database and options

func (*BulkInserter) InsertTableData

func (bi *BulkInserter) InsertTableData(ctx context.Context, tableData *TableData) error

InsertTableData performs bulk insertion of table data with transaction batching

type DDLManager

type DDLManager struct {
	// contains filtered or unexported fields
}

DDLManager handles schema creation with bulk DDL execution

func NewDDLManager

func NewDDLManager(db *Database) *DDLManager

NewDDLManager creates a new DDL manager

func (*DDLManager) CreateSchemas

func (dm *DDLManager) CreateSchemas(ctx context.Context, tables []dat.TableSchema) error

CreateSchemas creates all schemas using bulk execution for optimal performance

func (*DDLManager) CreateTableSchema

func (dm *DDLManager) CreateTableSchema(ctx context.Context, table *dat.TableSchema) error

CreateTableSchema creates the complete database schema for a table.

func (*DDLManager) GenerateTableDDL

func (dm *DDLManager) GenerateTableDDL(table *dat.TableSchema) (string, error)

GenerateTableDDL generates CREATE TABLE SQL for a given table schema

type DDLRequest

type DDLRequest struct {
	Type        string // "table" or "junction"
	DDL         string
	TableName   string
	Description string
}

DDLRequest represents a request to generate and execute DDL

type Database

type Database struct {
	// contains filtered or unexported fields
}

Database represents a connection to the ExileDB SQLite database

func NewDatabase

func NewDatabase(options *DatabaseOptions) (*Database, error)

NewDatabase creates a new database connection with the given options

func (*Database) BeginTx

func (d *Database) BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)

BeginTx starts a new transaction with the given options

func (*Database) Close

func (d *Database) Close() error

Close closes the database connection

func (*Database) Exec

func (d *Database) Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error)

Exec executes a SQL statement that doesn't return rows

func (*Database) HasUserTables

func (d *Database) HasUserTables(ctx context.Context) (bool, error)

HasUserTables checks if the database contains any user tables (non-system and non-metadata tables)

func (*Database) Query

func (d *Database) Query(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)

Query executes a SQL query that returns rows

func (*Database) QueryRow

func (d *Database) QueryRow(ctx context.Context, query string, args ...interface{}) *sql.Row

QueryRow executes a SQL query that is expected to return at most one row

type DatabaseOptions

type DatabaseOptions struct {
	// Path to the SQLite database file
	Path string

	// WALMode enables Write-Ahead Logging mode for better concurrency
	WALMode bool

	// ForeignKeys enables foreign key constraint checking
	ForeignKeys bool

	// BusyTimeout sets the timeout for locked database operations
	BusyTimeout time.Duration
}

DatabaseOptions configures database creation and connection behavior

func DefaultDatabaseOptions

func DefaultDatabaseOptions(path string) *DatabaseOptions

DefaultDatabaseOptions returns sensible default options for database connections

type RowData

type RowData struct {
	Index  int                    // Row index from DAT file
	Values map[string]interface{} // Column name -> value mapping
}

RowData represents a single row of data with column values

type TableData

type TableData struct {
	// Schema is the table schema from the community schema
	Schema *dat.TableSchema

	// Rows contains the parsed row data
	Rows []RowData

	// Metadata about the data
	Language string
}

TableData represents parsed data for a single table

Jump to

Keyboard shortcuts

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