當前位置: 首頁>>代碼示例>>Golang>>正文


Golang sqlite3.Conn類代碼示例

本文整理匯總了Golang中code/google/com/p/go-sqlite/go1/sqlite3.Conn的典型用法代碼示例。如果您正苦於以下問題:Golang Conn類的具體用法?Golang Conn怎麽用?Golang Conn使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Conn類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: isNewCache

func isNewCache(db *sqlite3.Conn, url, userId string) bool {

	query := fmt.Sprintf("SELECT id FROM notifications WHERE userid='%s' AND url='%s';", userId, url)

	_, err := db.Query(query)

	return err != nil
}
開發者ID:nilzen,項目名稱:gcnotify-go,代碼行數:8,代碼來源:main.go

示例2: notifyNewCache

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)
	}
}
開發者ID:nilzen,項目名稱:gcnotify-go,代碼行數:8,代碼來源:main.go

示例3: Finish

// 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
}
開發者ID:rwcarlsen,項目名稱:source-sink,代碼行數:12,代碼來源:walker.go

示例4: Prepare

// 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
}
開發者ID:rwcarlsen,項目名稱:source-sink,代碼行數:12,代碼來源:walker.go

示例5: createDatabaseSchema

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));")
	}
}
開發者ID:nilzen,項目名稱:gcnotify-go,代碼行數:10,代碼來源:main.go

示例6: InsertSessionActivity

// 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
}
開發者ID:haylingsailor,項目名稱:dbTests,代碼行數:12,代碼來源:main.go

示例7: InsertPerson

// 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
}
開發者ID:haylingsailor,項目名稱:dbTests,代碼行數:13,代碼來源:main.go

示例8: GetSimIds

// GetSimIds returns a list of all simulation ids in the cyclus database for
// conn.
func GetSimIds(conn *sqlite3.Conn) (ids []string, err error) {
	sql := "SELECT SimID FROM SimulationTimeInfo"
	var stmt *sqlite3.Stmt
	for stmt, err = conn.Query(sql); err == nil; err = stmt.Next() {
		var s string
		if err := stmt.Scan(&s); err != nil {
			return nil, err
		}
		ids = append(ids, s)
	}
	if err != io.EOF {
		return nil, err
	}
	return ids, nil
}
開發者ID:rwcarlsen,項目名稱:source-sink,代碼行數:17,代碼來源:util.go

示例9: exists_message_table

func exists_message_table(dbh *sqlite3.Conn) int {
	sql := "SELECT name FROM sqlite_master WHERE type='table' AND name='message';"

	flag := 0
	exists, err := dbh.Query(sql)

	if err == nil {
		if exists.Valid() {
			//			fmt.Println("found message db file")
			flag = 1
		}
	}

	return flag
}
開發者ID:vinian,項目名稱:iphone-sms-exporter,代碼行數:15,代碼來源:backup-sms.go

示例10: get_message_from_db

func get_message_from_db(dbh *sqlite3.Conn) {
	// datetime(message.date + 978307200, 'unixepoch', 'localtime') as m_date
	sql := `select chat.guid, message.text, message.date + 978307200 as m_date
        from chat, message where chat.account_id=message.account_guid order by
        chat.guid, message.date;`

	fmt.Println("Begin exporting ...")
	//	fmt.Println(sql)
	sms_backup_file := get_backup_file()
	out_file, err := os.OpenFile(sms_backup_file, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0600)
	if err != nil {
		fmt.Println("open sms out file error")
		log.Fatal(err)
	}
	defer out_file.Close()

	row := make(sqlite3.RowMap)
	for data, err := dbh.Query(sql); err == nil; err = data.Next() {
		data.Scan(row)
		if str, ok := row["text"].(string); ok {
			date_now := row["m_date"].(int64)
			sms_time := time.Unix(date_now, 0)
			phone_number := get_phone_number(row["guid"])
			sms := phone_number + " " + sms_time.String() + " " + str
			if _, err := out_file.WriteString(sms); err != nil {
				fmt.Println("write sms file error")
				log.Fatal(err)
			}
			if strings.EqualFold(runtime.GOOS, "windows") {
				out_file.WriteString("\r\n")
			} else {
				out_file.WriteString("\n")
			}
		} else {
			fmt.Println("interface to string error")
			fmt.Println(row)
		}
	}

	fmt.Println("Export OK")
}
開發者ID:vinian,項目名稱:iphone-sms-exporter,代碼行數:41,代碼來源:backup-sms.go


注:本文中的code/google/com/p/go-sqlite/go1/sqlite3.Conn類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。