Documentation ¶
Overview ¶
Copyright (c) 2021 Kamiar Bahri
Index ¶
- Constants
- func Decrypt(data []byte, passphrase string) ([]byte, error)
- func DecryptFile(p string, pwdPhrase string) error
- func Encrypt(plainData []byte, passphrase string) ([]byte, error)
- func EncryptFile(p string, pwdPhrase string) error
- type CollectionInfo
- type DBAccess
- func (d *DBAccess) AddDBFileToShrinkWatchList(dbFilePath string)
- func (d *DBAccess) AppendDataTable(dtSrce *collc.Table, dtDest *collc.Table) (*collc.Table, error)
- func (dc *DBAccess) BulkInsert(dtSrc *collc.Table, dbFilePath string, notify func(status string)) error
- func (d *DBAccess) CloneDataTable(dtSrce *collc.Table) (*collc.Table, error)
- func (dc *DBAccess) CloneDatabase(srcFilePath string, destFilePath string, notify func(status string)) error
- func (d *DBAccess) CreateNewDatabase(tbl *collc.Table, dbFilePath string) (int64, error)
- func (d *DBAccess) DatabaseExists(path string) bool
- func (d *DBAccess) Decrypt(data []byte, pwdPhrase string) ([]byte, error)
- func (d *DBAccess) DecryptDatabase(dbFilePath string, pwdPhrase string) error
- func (d *DBAccess) Encrypt(data []byte, pwdPhrase string) ([]byte, error)
- func (d *DBAccess) EncryptDatabase(dbFilePath string, pwdPhrase string) error
- func (d *DBAccess) ExecuteNonQuery(sqlStatement string, dbFilePath string) (int64, error)
- func (d *DBAccess) ExecuteNonQueryNoTx(sqlStatement string, dbFilePath string) (int64, error)
- func (d *DBAccess) ExecuteNonQueryNoTxPointToDB(sqlStatement string, db *sql.DB) (int64, error)
- func (d *DBAccess) ExecuteNonQueryPointToDB(sqlStatement string, db *sql.DB) (int64, error)
- func (d *DBAccess) ExecuteScalare(sqlStatement string, dbFilePath string) (interface{}, error)
- func (d *DBAccess) ExecuteScalarePointToDB(sqlStatement string, db *sql.DB) (interface{}, error)
- func (d *DBAccess) ExportDataTableToDatabase(tbl *collc.Table, dbFilePath string) (int64, error)
- func (d *DBAccess) GetColumnNames(dbFilePath string, tblName string) ([]string, error)
- func (d *DBAccess) GetDB(dbFilePath string) (*sql.DB, error)
- func (d *DBAccess) GetDataMap(sqlQuery string, dbFilePath string) ([]map[string]interface{}, error)
- func (d *DBAccess) GetDataMapPage(sqlQuery string, pageNo int, pageSize int, dbFilePath string) ([]map[string]interface{}, error)
- func (d *DBAccess) GetDataMapPointToDB(sqlQuery string, db *sql.DB) ([]map[string]interface{}, error)
- func (d *DBAccess) GetDataTable(sqlQuery string, dbFilePath string) (*collc.Table, error)
- func (d *DBAccess) GetDataTableJSON(tbl *collc.Table) string
- func (dc *DBAccess) GetDataTableLongQuery(sqlQuery string, dbFilePath string, pageSize int, ...) (*collc.Table, error)
- func (d *DBAccess) GetDataTableRange(dtSrc *collc.Table, dtDest *collc.Table, from int, to int) error
- func (d *DBAccess) GetDataTableWithTag(sqlQuery string, dbFilePath string, tag string) (*collc.Table, error)
- func (d *DBAccess) GetPageInfoFromQuery(r *http.Request) (int, int)
- func (d *DBAccess) GetPageOffset(recordCount int, pageSize int, pageNo int) (int, int, int)
- func (d *DBAccess) GetPagingInfo(pageSize int, pageNo int, tableName string, countColName string, filter string, ...) (int, int, CollectionInfo)
- func (d *DBAccess) GetShrinkWatchList() []string
- func (d *DBAccess) GetTableCount(tableName string, dbFilePath string) (int64, error)
- func (d *DBAccess) InsertDataTable(t *collc.Table, dbFilePath string, wg *sync.WaitGroup) (int64, error)
- func (d *DBAccess) InsertSingleRow(t *collc.Table, rowInx int, dbFilePath string) (int64, error)
- func (d *DBAccess) ShrinkDB(dbFilePath string) error
- type LonqQueryArgs
Constants ¶
const ( Err_DatabaseIsLocked = "database is locked" Err_FileIsNotDatabase = "file is not a database" Err_DatabaseFileNotExists = "database file does not exist" Err_NoRowsFound = "no rows found" )
Variables ¶
This section is empty.
Functions ¶
func DecryptFile ¶
DecryptFile decryptes a file using the AES algorythm.
func EncryptFile ¶
Encrypt encryptes a file using the AES algorythm.
Types ¶
type CollectionInfo ¶
type CollectionInfo struct { RecordCount int TotalPages int PageSize int PageNo int PositionFrom int PositionTo int }
CollectionInfo holds Grid info for use in the client javascript.
type DBAccess ¶
type DBAccess struct { MaxIdleConns uint MaxOpenConns uint PRAGMA []string ShrinkDatabaseFiles bool // ShrinkWatchList keeps a list of sqlite database // file paths that are to be shrinked in a set internval. ShrinkWatchList []string // contains filtered or unexported fields }
func NewDBAccess ¶
func (*DBAccess) AddDBFileToShrinkWatchList ¶
AddDBFileToShrinkWatchList adds an SQLite database file path to a watch list for monitoring.
func (*DBAccess) AppendDataTable ¶
func (*DBAccess) BulkInsert ¶
func (dc *DBAccess) BulkInsert(dtSrc *collc.Table, dbFilePath string, notify func(status string)) error
BulkInsert inserts a DataTable into a database.
func (*DBAccess) CloneDataTable ¶
CloneDataTable retuns a copy of a DataTable.
func (*DBAccess) CloneDatabase ¶
func (dc *DBAccess) CloneDatabase(srcFilePath string, destFilePath string, notify func(status string)) error
CloneDatabase copies one database to the other.
func (*DBAccess) CreateNewDatabase ¶
func (*DBAccess) DatabaseExists ¶
DatabaseExists checks existance of the db file.
func (*DBAccess) DecryptDatabase ¶
func (*DBAccess) EncryptDatabase ¶
func (*DBAccess) ExecuteNonQuery ¶
ExecuteNonQuery inserts data. It uses a transaction context so that the operation is rolled back on failures and then closes the database. Closing the databases has the following advantages for an SQLite database:
- It reduces chances of file corruption.
- It reduces chances of "database locked" errors.
- It reduces lingering locks, where the database file stays locked albite closing all database handles.
func (*DBAccess) ExecuteNonQueryNoTx ¶
ExecuteNonQueryNoTx uses no transaction context to insert data.
func (*DBAccess) ExecuteNonQueryNoTxPointToDB ¶
func (*DBAccess) ExecuteNonQueryPointToDB ¶
ExecuteNonQueryPointToDB inserts data. It does not close the database after operation is completed.
func (*DBAccess) ExecuteScalare ¶
ExecuteScalare returns one value and closes the database.
func (*DBAccess) ExecuteScalarePointToDB ¶
ExecuteScalare returns one value and closes the database.
func (*DBAccess) ExportDataTableToDatabase ¶
ExportDataTableToDatabase creates a new table based on a Table. It creates a new table if table not exists. By default if the db file does not exist, it will be created.
func (*DBAccess) GetColumnNames ¶
GetColumnNames gets the column names of a table.
func (*DBAccess) GetDB ¶
GetDB opens a database, while attempting to clear a lingering lock on an sqlite database file. If the db is locked or the previous call did not close the db after writing, this will close the db -- and reset the db mode for read/write operations.
func (*DBAccess) GetDataMap ¶
GetDataMap gets a selected range of table in form of rows and columns.
func (*DBAccess) GetDataMapPage ¶ added in v1.0.2
func (d *DBAccess) GetDataMapPage(sqlQuery string, pageNo int, pageSize int, dbFilePath string) ([]map[string]interface{}, error)
GetDataMapPage returns a map of query by page.
func (*DBAccess) GetDataMapPointToDB ¶
func (d *DBAccess) GetDataMapPointToDB(sqlQuery string, db *sql.DB) ([]map[string]interface{}, error)
GetDataMapPointToDB gets a selected range of table in form of rows and columns and keep the keeps the database open.
func (*DBAccess) GetDataTable ¶
func (*DBAccess) GetDataTableLongQuery ¶
func (*DBAccess) GetDataTableRange ¶
func (d *DBAccess) GetDataTableRange(dtSrc *collc.Table, dtDest *collc.Table, from int, to int) error
GetDataTableRange selects a range from a DataTable.
func (*DBAccess) GetDataTableWithTag ¶
func (*DBAccess) GetPageInfoFromQuery ¶
GetPageInfoFromQuery --
func (*DBAccess) GetPageOffset ¶
GetPageOffset returns totalPages, offset, pageNo
func (*DBAccess) GetPagingInfo ¶
func (d *DBAccess) GetPagingInfo(pageSize int, pageNo int, tableName string, countColName string, filter string, dbFilePath string) (int, int, CollectionInfo)
GetPagingInfo returns pageSize, offset, and collection info.
func (*DBAccess) GetShrinkWatchList ¶
GetShrinkWatchList return the global string array of the db file paths.
func (*DBAccess) GetTableCount ¶
func (*DBAccess) InsertDataTable ¶
func (d *DBAccess) InsertDataTable(t *collc.Table, dbFilePath string, wg *sync.WaitGroup) (int64, error)
InsertDataTable inserts a DataTable collection into a datbase table. The table has to exists and all columns must match the table from the arg.