gopherbouncesqlite

package module
v0.0.0-...-fd0a11d Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

README

gopherbouncesqlite

SQLite bindings for the gopherbouncedb package

Documentation

Overview

Package gopherbouncesqlite provides sqlite3 bindings for the gopherbounce package. Because the sqlite driver has some flaws (for example no concurrency support on writes) it should not be used in production code. Use the MySQL or Postgres driver instead.

Index

Constants

View Source
const (
	SqliteUsersInit = `` /* 415-byte string literal not displayed */

	SqliteUsernameIndex = `CREATE UNIQUE INDEX IF NOT EXISTS
idx_$USERS_TABLE_NAME$_username ON $USERS_TABLE_NAME$(username);`

	SqliteEmailIndex = `CREATE $EMAIL_UNIQUE$ INDEX IF NOT EXISTS
idx_$USERS_TABLE_NAME$_email ON $USERS_TABLE_NAME$(email);`

	SqliteQueryUserID = `SELECT * FROM $USERS_TABLE_NAME$ WHERE id=?;`

	SqliteQueryUsername = `SELECT * FROM $USERS_TABLE_NAME$ WHERE username=?;`

	SqliteQueryEmail = `SELECT * FROM $USERS_TABLE_NAME$ WHERE email=?;`

	SqliteInsertUser = `` /* 179-byte string literal not displayed */

	SqliteUpdateUser = `` /* 171-byte string literal not displayed */

	SqliteDeleteUser = `DELETE FROM $USERS_TABLE_NAME$ WHERE id=?;`

	SqliteUpdateUserFields = `UPDATE $USERS_TABLE_NAME$
SET $UPDATE_CONTENT$
WHERE id = ?;`

	SqliteListUsers = `SELECT * FROM $USERS_TABLE_NAME$;`

	SqliteSessionInit = `` /* 229-byte string literal not displayed */

	SqliteInsertSession = `INSERT INTO $SESSIONS_TABLE_NAME$(
session_key, user, expire_date) VALUES(?, ?, ?);`

	SqliteGetSession = `SELECT * FROM $SESSIONS_TABLE_NAME$ WHERE session_key=?;`

	SqliteDeleteSession = `DELETE FROM $SESSIONS_TABLE_NAME$ WHERE session_key=?;`

	SqliteCleanUpSession = `DELETE FROM $SESSIONS_TABLE_NAME$ WHERE expire_date < ?;`

	SqliteDeleteForUser = `DELETE FROM $SESSIONS_TABLE_NAME$ WHERE user=?;`
)

Variables

View Source
var (
	DefaultSQLiteUserRowNames = gopherbouncedb.DefaultUserRowNames
)

Functions

func DefaultSQLiteReplacer

func DefaultSQLiteReplacer() *gopherbouncedb.SQLTemplateReplacer

DefaultSQLiteReplacer returns the default sql replacer for sqlite3 (see gopherbouncedb.SQLTemplateReplacer). It's the same as gopherbouncedb.DefaultSQLReplacer.

Types

type SQLiteBridge

type SQLiteBridge struct{}

SQLiteBridge implements gopherbouncedb.SQLBridge.

func NewSQLiteBridge

func NewSQLiteBridge() SQLiteBridge

func (SQLiteBridge) ConvertTime

func (b SQLiteBridge) ConvertTime(t time.Time) interface{}

func (SQLiteBridge) ConvertTimeScanType

func (b SQLiteBridge) ConvertTimeScanType(val interface{}) (time.Time, error)

func (SQLiteBridge) IsDuplicateInsert

func (b SQLiteBridge) IsDuplicateInsert(err error) bool

func (SQLiteBridge) IsDuplicateUpdate

func (b SQLiteBridge) IsDuplicateUpdate(err error) bool

func (SQLiteBridge) TimeScanType

func (b SQLiteBridge) TimeScanType() interface{}

type SQLiteSessionStorage

type SQLiteSessionStorage struct {
	*gopherbouncedb.SQLSessionStorage
}

SQLiteSessionStorage is as session storage based on sqlite3.

func NewSQLiteSessionStorage

func NewSQLiteSessionStorage(db *sql.DB, replaceMapping map[string]string) *SQLiteSessionStorage

NewSQLiteSessionStorage creates a new sqlite session storage given the database connection and the replacement mapping used to create the queries with NewSqliteSessionQueries.

If you want to configure any options please read the gopherbounce wiki.

type SQLiteStorage

type SQLiteStorage struct {
	*SQLiteUserStorage
	*SQLiteSessionStorage
}

SQLiteStorage combines a user storage and a session storage (both based on sqlite3) to implement gopherbouncedb.Storage.

func NewSQLiteStorage

func NewSQLiteStorage(db *sql.DB, replaceMapping map[string]string) *SQLiteStorage

NewSQLiteStorage returns a new SQLiteStorage.

type SQLiteUserQueries

type SQLiteUserQueries struct {
	// The slice of init statements.
	// By default contains a create table and two create index (username and email)
	// statements.
	InitS []string
	// The default queries.
	GetUserS, GetUserByNameS, GetUserByEmailS, InsertUserS,
	UpdateUserS, DeleteUserS, UpdateFieldsS, ListUsersS string
	// The replacer that was used to create the query strings from the strings with
	// meta variables.
	Replacer *gopherbouncedb.SQLTemplateReplacer
	// Used to lookup row names, defaults to DefaultSQLiteUserRowNames.
	RowNames map[string]string
}

SQLiteUserQueries implements gopherbouncedb.UserSQL with support for sqlite3.

func NewSQLiteUserQueries

func NewSQLiteUserQueries(replaceMapping map[string]string) *SQLiteUserQueries

NewSQLiteUserQueries returns new queries given the replacement mapping that is used to update the default replacer.

That is it uses the default sqlite3 replacer, but updates the fields given in replaceMapping to overwrite existing values / insert new ones.

The initialization queries don't contain the creation of an index for the username

and email. sqlite automatically creates an index for unique fields in general.

func (*SQLiteUserQueries) DeleteUser

func (q *SQLiteUserQueries) DeleteUser() string

func (*SQLiteUserQueries) GetUser

func (q *SQLiteUserQueries) GetUser() string

func (*SQLiteUserQueries) GetUserByEmail

func (q *SQLiteUserQueries) GetUserByEmail() string

func (*SQLiteUserQueries) GetUserByName

func (q *SQLiteUserQueries) GetUserByName() string

func (*SQLiteUserQueries) InitUsers

func (q *SQLiteUserQueries) InitUsers() []string

func (*SQLiteUserQueries) InsertUser

func (q *SQLiteUserQueries) InsertUser() string

func (*SQLiteUserQueries) ListUsers

func (q *SQLiteUserQueries) ListUsers() string

func (*SQLiteUserQueries) SupportsUserFields

func (q *SQLiteUserQueries) SupportsUserFields() bool

func (*SQLiteUserQueries) UpdateUser

func (q *SQLiteUserQueries) UpdateUser(fields []string) string

type SQLiteUserStorage

type SQLiteUserStorage struct {
	*gopherbouncedb.SQLUserStorage
}

SQLiteUserStorage is a user storage based on sqlite3.

func NewSQLiteUserStorage

func NewSQLiteUserStorage(db *sql.DB, replaceMapping map[string]string) *SQLiteUserStorage

NewSQLiteUserStorage creates a new sqlite user storage given the database connection and the replacement mapping used to create the queries with NewSQLiteUserQueries.

If you want to configure any options please read the gopherbounce wiki.

type SqliteSessionQueries

type SqliteSessionQueries struct {
	InitS                                                                               []string
	InsertSessionS, GetSessionS, DeleteSessionS, CleanUpSessionS, DeleteForUserSessionS string
	Replacer                                                                            *gopherbouncedb.SQLTemplateReplacer
}

SqliteSessionQueries implements gopherbouncedb.SessionSQL with support for sqlite3.

func NewSqliteSessionQueries

func NewSqliteSessionQueries(replaceMapping map[string]string) *SqliteSessionQueries

NewSqliteSessionQueries returns new queries given the replacement mapping that is used to update the default replacer.

That is it uses the default sqlite3 replacer, but updates the fields given in replaceMapping to overwrite existing values / insert new ones.

func (*SqliteSessionQueries) CleanUpSession

func (q *SqliteSessionQueries) CleanUpSession() string

func (*SqliteSessionQueries) DeleteForUserSession

func (q *SqliteSessionQueries) DeleteForUserSession() string

func (*SqliteSessionQueries) DeleteSession

func (q *SqliteSessionQueries) DeleteSession() string

func (*SqliteSessionQueries) GetSession

func (q *SqliteSessionQueries) GetSession() string

func (*SqliteSessionQueries) InitSessions

func (q *SqliteSessionQueries) InitSessions() []string

func (*SqliteSessionQueries) InsertSession

func (q *SqliteSessionQueries) InsertSession() string

Jump to

Keyboard shortcuts

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