rdblite3

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2022 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

This package is wrapper for sqlite3 db connections. To use it with your own structs, you have to add an column-tag to your structs and an ID field.

This package is currently in a BETA-state.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SQLite3

type SQLite3 struct {
	Destination string `json:"destination"`
	// contains filtered or unexported fields
}

sqlite3 struct to group informations, json ready

func (*SQLite3) CheckConnection

func (sql3 *SQLite3) CheckConnection() error

check connection to dbfile

func (*SQLite3) Connect

func (sql3 *SQLite3) Connect()

connect to the sqlite database file

func (SQLite3) DB

func (sql3 SQLite3) DB() *sql.DB

get the db pointer from the sqlite3 pkg

func (SQLite3) DeleteObject

func (sql3 SQLite3) DeleteObject(tblName string, obj interface{}) (err error)

this function generates an "delete" statement, where the given struct is used to delete the object from the given table. The function requires the object struct to have an "ID" field with a valid value.

Parameters:

  • `tblName` : string > the name of the table, where tho object is estimated
  • `obj` : interface{} | struct > the object with an ID-field and an valid value

func (SQLite3) Disconnect

func (sql3 SQLite3) Disconnect() error

disconnect from the currently connected file

func (SQLite3) InsertObject

func (sql3 SQLite3) InsertObject(tblName string, objPointer, obj interface{}) (err error)

this function generates an "insert" statement, where the given struct is inserted into the given table. The function requires the object struct to have an "ID" field, so the struct receives the new id.

Parameters:

  • `tblName` : string > the name of the table, where tho object is estimated
  • `objPointer` : interface{} | *struct > pointer to the object, is used to get the struct-informations
  • `obj` : interface{} | struct > the same object, but not as a pointer, is used to get the struct-informations

func (SQLite3) SelectObject

func (sql3 SQLite3) SelectObject(tblName string, objPointer, obj interface{}) (err error)

this function generates a "select" statement, where the estimated object is exactly one object, not from a list. The function requires the object- struct to have an "ID" field.

Parameters:

  • `tblName` : string > the name of the table, where tho object is estimated
  • `objPointer` : interface{} | *struct > pointer to the object, is used to get the struct-informations
  • `obj` : interface{} | struct > the same object, but not as a pointer, where the data should be stored

func (SQLite3) SelectObjects

func (sql3 SQLite3) SelectObjects(tblName string, objPointer interface{}) (err error)

this function generates a "select" statement, where the estimated object is a list of objects. The function does not require the object struct to have an "ID" field.

Parameters:

  • `tblName` : string > the name of the table, where tho object is estimated
  • `objPointer` : interface{} | *[]struct > contains the list of the array

func (SQLite3) SpecificSelectObject

func (sql3 SQLite3) SpecificSelectObject(sqlStatement string, objPointer interface{}) (err error)

this function uses a specified sql-statement to select multiple objects. the statement will be given through the variable sqlStatement <string>

Parameters:

  • `sqlStatement` : string > the sql stateent, which is used to receive the objects
  • `objPointer` : interface{} | *struct > contains the pointer to the object -> *[]struct

func (SQLite3) SpecificSelectObjects

func (sql3 SQLite3) SpecificSelectObjects(sqlStatement string, objPointer interface{}) (err error)

this function uses a specified sql-statement to select multiple objects. the statement will be given through the variable sqlStatement <string>

Parameters:

  • `sqlStatement` : string > the sql stateent, which is used to receive the objects
  • `objPointer` : interface{} | *[]struct > contains the list of the objects

func (SQLite3) UpdateObject

func (sql3 SQLite3) UpdateObject(tblName string, objPointer, obj interface{}) (err error)

this function generates an "update" statement, where the given struct updates the values in the given table. The function requires the object struct to have an "ID" field, so the table receives the new values.

Parameters:

  • `tblName` : string > the name of the table, where tho object is estimated
  • `objPointer` : interface{} | *struct > pointer to the object, is used to store the values
  • `obj` : interface{} | struct > the same object, but not as a pointer, is used to get the struct-informations

Jump to

Keyboard shortcuts

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