本文整理匯總了Golang中camli/third_party/github.com/Philio/GoMySQL.Client類的典型用法代碼示例。如果您正苦於以下問題:Golang Client類的具體用法?Golang Client怎麽用?Golang Client使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Client類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: do
func do(db *mysql.Client, sql string) {
err := db.Query(sql)
if err == nil {
return
}
exitf("Error %v running SQL: %s", err, sql)
}
示例2: ReceiveBlob
func (mi *Indexer) ReceiveBlob(blobRef *blobref.BlobRef, source io.Reader) (retsb blobref.SizedBlobRef, err os.Error) {
sniffer := new(blobSniffer)
hash := blobRef.Hash()
var written int64
written, err = io.Copy(io.MultiWriter(hash, sniffer), source)
log.Printf("mysqlindexer: hashed+sniffed %d bytes; err %v", written, err)
if err != nil {
return
}
if !blobRef.HashMatches(hash) {
err = blobserver.ErrCorruptBlob
return
}
sniffer.Parse()
mimeType := sniffer.MimeType()
log.Printf("mysqlindexer: type=%v; truncated=%v", mimeType, sniffer.IsTruncated())
var client *mysql.Client
if client, err = mi.getConnection(); err != nil {
return
}
defer mi.releaseConnection(client)
var stmt *mysql.Statement
if stmt, err = client.Prepare("INSERT IGNORE INTO blobs (blobref, size, type) VALUES (?, ?, ?)"); err != nil {
log.Printf("mysqlindexer: prepare error: %v", err)
return
}
if err = stmt.BindParams(blobRef.String(), written, mimeType); err != nil {
log.Printf("mysqlindexer: bind error: %v", err)
return
}
if err = stmt.Execute(); err != nil {
log.Printf("mysqlindexer: execute error: %v", err)
return
}
if camli := sniffer.camli; camli != nil {
switch camli.Type {
case "claim":
if err = mi.populateClaim(client, blobRef, camli, sniffer); err != nil {
return
}
case "permanode":
if err = mi.populatePermanode(client, blobRef, camli); err != nil {
return
}
case "file":
if err = mi.populateFile(client, blobRef, camli); err != nil {
return
}
}
}
retsb = blobref.SizedBlobRef{BlobRef: blobRef, Size: written}
return
}
示例3: execSQL
func execSQL(client *mysql.Client, sql string, args ...interface{}) (err os.Error) {
var stmt *mysql.Statement
if stmt, err = client.Prepare(sql); err != nil {
log.Printf("mysqlindexer execSQL prepare: %v", err)
return
}
if err = stmt.BindParams(args...); err != nil {
log.Printf("mysqlindexer execSQL bind: %v", err)
return
}
if err = stmt.Execute(); err != nil {
log.Printf("mysqlindexer execSQL exe: %v", err)
return
}
return
}
示例4: dbExists
func dbExists(db *mysql.Client, dbname string) bool {
check(db.Query("SHOW DATABASES"))
result, err := db.UseResult()
check(err)
defer result.Free()
for {
row := result.FetchRow()
if row == nil {
break
}
if row[0].(string) == dbname {
return true
}
}
return false
}
示例5: EnumerateBlobs
func (mi *Indexer) EnumerateBlobs(dest chan<- blobref.SizedBlobRef, after string, limit uint, waitSeconds int) (err os.Error) {
// MySQL connection stuff.
var client *mysql.Client
client, err = mi.getConnection()
if err != nil {
return
}
defer mi.releaseConnection(client)
var stmt *mysql.Statement
stmt, err = client.Prepare("SELECT blobref, size FROM blobs WHERE blobref > ? ORDER BY blobref LIMIT ?")
if err != nil {
return
}
err = stmt.BindParams(after, limit)
if err != nil {
return
}
err = stmt.Execute()
if err != nil {
return
}
var row blobRow
stmt.BindResult(&row.blobref, &row.size)
for {
var done bool
done, err = stmt.Fetch()
if err != nil {
return
}
if done {
break
}
br := blobref.Parse(row.blobref)
if br == nil {
continue
}
dest <- blobref.SizedBlobRef{
BlobRef: br,
Size: row.size,
}
}
close(dest)
return
}
示例6: SchemaVersion
func (mi *Indexer) SchemaVersion() (version int, err os.Error) {
var client *mysql.Client
client, err = mi.getConnection()
if err != nil {
return
}
defer mi.releaseConnection(client)
err = client.Query("SELECT value FROM meta WHERE metakey='version'")
if err != nil {
return
}
res, err := client.UseResult()
if err != nil {
return
}
row := res.FetchRow()
if row == nil {
return 0, nil
}
version, err = strconv.Atoi(row[0].(string))
client.FreeResult()
return
}
示例7: IsAlive
func (mi *Indexer) IsAlive() (ok bool, err os.Error) {
var client *mysql.Client
client, err = mi.getConnection()
if err != nil {
return
}
defer mi.releaseConnection(client)
err = client.Query("SELECT 1 + 1")
if err != nil {
return
}
_, err = client.UseResult()
if err != nil {
return
}
client.FreeResult()
return true, nil
}