db

package
v0.0.0-...-2015c5d Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDevMode

func GetDevMode() bool

func GetDuckDBConnection

func GetDuckDBConnection() (*sql.DB, error)

GetDuckDBConnection returns the a Screentime DuckDB connection

func GetDuckDBFilename

func GetDuckDBFilename() string

GetDuckDBFilename returns the DuckDB filename.

func GetDuckdbSafeMigrationEmbed

func GetDuckdbSafeMigrationEmbed() string

func GetDuckdbUpMigrationEmbed

func GetDuckdbUpMigrationEmbed() string

func GetDuckdbViewsMigration

func GetDuckdbViewsMigration() string

func GetDuckdbViewsMigrationEmbed

func GetDuckdbViewsMigrationEmbed() string

func Open

func Open(filename string) (*sql.DB, error)

Open opens a connection to the DuckDB database.

func RowsToCSV

func RowsToCSV(rows *sql.Rows) (string, error)

RowsToCSV converts sql.Rows rows to a CSV string.

func RunMigration

func RunMigration(conn *sql.DB) error

RunMigration executes the migration string on the DuckDB connection. Returns an error, if any.

func RunSafeMode

func RunSafeMode(conn *sql.DB) error

RunSafeMode locks the database down with the DuckdbSafeMigration. Returns an error, if any

func SetDevMode

func SetDevMode(isOn bool)

func SetDuckDBFilename

func SetDuckDBFilename(filename string)

SetDuckDBFilename sets the DuckDB filename. Default is :memory:

func String

func String(str string) string

String internally quotes a string for use in a SQL query.

Types

type MigrationInfo

type MigrationInfo struct {
	HomeDir      string
	TimezoneInfo TimezoneInfo
}

MigrationInfo holds data to be injected by our migration template

type TimezoneInfo

type TimezoneInfo struct {
	Timestamp        int64  `json:"timestamp"`
	Location         string `json:"location"`
	Timezone         string `json:"timezone"`
	UTCOffsetSeconds int    `json:"offset"`
	IsDST            bool   `json:"is_dst"`
	IsWeekend        bool   `json:"is_weekend"`
	DayOfWeek        int    `json:"day_of_week"`
}

TimezoneInfo represents timezone information for the database

Jump to

Keyboard shortcuts

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