sqlite

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2021 License: LGPL-2.1 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateOrOpenDb added in v0.0.3

func CreateOrOpenDb(name string) *sql.DB

Types

type AdvancedSqliteApi added in v0.0.4

type AdvancedSqliteApi struct {
	core.DbApi
	Cols        map[string]string
	FuncOnError func(err error)
	IsImportant bool
}

AdvancedSqliteApi just has more automation Cols is a map with all columns example:

map[string]string{
	"id": "INTEGER PRIMARY KEY AUTOINCREMENT",
	"name": "TEXT"
}

WARNING: do not put ',' or ')' no need in it FuncOnError is a custom function that will be called on error if isImportant is true

func NewAdvancedSqliteApi added in v0.0.4

func NewAdvancedSqliteApi(db *sql.DB, tableName string, cols map[string]string, customErrorFunction func(err error), isImportant bool) AdvancedSqliteApi

func (*AdvancedSqliteApi) Sync added in v0.0.4

func (asapi *AdvancedSqliteApi) Sync() error

type SqliteApi

type SqliteApi struct {
	core.DbApi
}

SqliteApi structure is a structure that will interact with sqlite

func CreateSqliteApi

func CreateSqliteApi(db *sql.DB, tableName string) SqliteApi

func (*SqliteApi) DeleteAllBy

func (sapi *SqliteApi) DeleteAllBy(cond string) error

it will delete all rows in db with specified condition

example: name="muka" AND id=1

func (*SqliteApi) DeleteById added in v0.0.2

func (sapi *SqliteApi) DeleteById(id int) error

func (*SqliteApi) DropTable

func (sapi *SqliteApi) DropTable() error

if you need to drop table just use it

func (*SqliteApi) Insert

func (sapi *SqliteApi) Insert(cols string, values string) error

argument 'cols' is a string where you put all columns in which values will be inserted example: name, email argument 'values' is a string with values that will be inserted example: "muka", "cringer@asd.dq"

func (*SqliteApi) SelectAll

func (sapi *SqliteApi) SelectAll() *sql.Rows

if you need to get all rows just use it WARNING: it's returns *sql.Rows that means that other work you need to do on your own

func (*SqliteApi) SelectById added in v0.0.2

func (sapi *SqliteApi) SelectById(id int) *sql.Row

it will select item by id

func (*SqliteApi) Sync

func (sapi *SqliteApi) Sync(cols string) error

sync means "create table if not exists" argument 'cols' is just columns with all attributes example: "id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT"

func (*SqliteApi) UpdateById added in v0.0.2

func (sapi *SqliteApi) UpdateById(id int, updates string) error

this function will update a row with id that you will provide updates argument is a string with all cols need to be updated example: name = "muka", email = "cri@avd.fs"

Jump to

Keyboard shortcuts

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