Beispiel #1
0
func notifyNewCache(db *sqlite3.Conn, cacheUrl, title string, settings SettingsObject) {

	if sendPush(title, cacheUrl, settings) {
		sql := fmt.Sprintf("INSERT INTO notifications (url, title, userid) VALUES ('%s', '%s', '%s');", cacheUrl, title, settings.GeocachingUserId)

		db.Exec(sql)
	}
}
Beispiel #2
0
// Finish should be called for a cyclus database after all walkers have
// completed processing inventory data. It creates final indexes and other
// finishing tasks.
func Finish(conn *sqlite3.Conn) (err error) {
	fmt.Println("Creating inventory indexes...")
	for _, sql := range postExecStmts {
		if err := conn.Exec(sql); err != nil {
			return err
		}
	}
	return nil
}
Beispiel #3
0
// Prepare creates necessary indexes and tables required for efficient
// calculation of cyclus simulation inventory information.  Should be called
// once before walking begins.
func Prepare(conn *sqlite3.Conn) (err error) {
	fmt.Println("Creating indexes and inventory table...")
	for _, sql := range preExecStmts {
		if err := conn.Exec(sql); err != nil {
			fmt.Println("    ", err)
		}
	}
	return nil
}
Beispiel #4
0
func createDatabaseSchema(db *sqlite3.Conn) {

	query := "SELECT name FROM sqlite_master WHERE type='table' AND name='notifications';"

	_, err := db.Query(query)

	if err != nil {
		db.Exec("CREATE TABLE notifications (id INTEGER PRIMARY KEY AUTOINCREMENT, userid VARCHAR(36), url VARCHAR(256), title VARCHAR(256));")
	}
}
Beispiel #5
0
// InsertSessionActivity blah
func InsertSessionActivity(conn *sqlite.Conn, personID int) (err error) {
	args := sqlite.NamedArgs{
		"$personId": personID,
	}

	err = conn.Exec(
		`INSERT OR IGNORE INTO mem.sessionActivity (personId)
           VALUES($personId);
        `, args)
	return
}
Beispiel #6
0
// InsertPerson blah
func InsertPerson(conn *sqlite.Conn, id int, name string) (err error) {
	args := sqlite.NamedArgs{
		"$id":   id,
		"$name": name,
	}

	err = conn.Exec(
		`INSERT OR IGNORE INTO main.person (id, name)
            VALUES($id, $name);
        `, args)
	return
}