本文整理汇总了Golang中C.sqlite3_column_name函数的典型用法代码示例。如果您正苦于以下问题:Golang sqlite3_column_name函数的具体用法?Golang sqlite3_column_name怎么用?Golang sqlite3_column_name使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sqlite3_column_name函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Query
func (s *stmt) Query(args []driver.Value) (driver.Rows, error) {
if s.closed {
panic("database/sql/driver: misuse of sqlite driver: Query after Close")
}
if s.rows {
panic("database/sql/driver: misuse of sqlite driver: Query with active Rows")
}
err := s.start(args)
if err != nil {
return nil, err
}
s.rows = true
if s.colnames == nil {
n := int64(C.sqlite3_column_count(s.stmt))
s.colnames = make([]string, n)
s.coltypes = make([]string, n)
for i := range s.colnames {
s.colnames[i] = C.GoString(C.sqlite3_column_name(s.stmt, C.int(i)))
s.coltypes[i] = strings.ToLower(C.GoString(C.sqlite3_column_decltype(s.stmt, C.int(i))))
}
}
return &rows{s}, nil
}
示例2: ColumnName
// ColumnName returns the name of the Nth column of the result set returned by the SQL statement. (not cached)
// The leftmost column is number 0.
// (See http://sqlite.org/c3ref/column_name.html)
func (s *Stmt) ColumnName(index int) string {
if index < 0 || index >= s.ColumnCount() {
panic(fmt.Sprintf("column index %d out of range [0,%d[.", index, s.ColumnCount()))
}
// If there is no AS clause then the name of the column is unspecified and may change from one release of SQLite to the next.
return C.GoString(C.sqlite3_column_name(s.stmt, C.int(index)))
}
示例3: Columns
func (rows Rows) Columns() []string {
count := int(C.sqlite3_column_count(rows.stmt))
cols := make([]string, count)
for i := 0; i < count; i++ {
cols[i] = C.GoString(C.sqlite3_column_name(rows.stmt, C.int(i)))
}
return cols
}
示例4: Columns
// Return column names.
func (rc *SQLiteRows) Columns() []string {
if rc.nc != len(rc.cols) {
rc.cols = make([]string, rc.nc)
for i := 0; i < rc.nc; i++ {
rc.cols[i] = C.GoString(C.sqlite3_column_name(rc.s.s, C.int(i)))
}
}
return rc.cols
}
示例5: Columns
// Columns returns the names of columns produced by the prepared statement.
// [http://www.sqlite.org/c3ref/column_name.html]
func (s *Stmt) Columns() []string {
if len(s.colNames) != s.nCols {
names := resize(s.colNames, s.nCols)
for i, old := range names {
new := goStr(C.sqlite3_column_name(s.stmt, C.int(i)))
if old != new {
names[i] = raw(new).Copy()
}
}
s.colNames = names
}
return s.colNames
}
示例6: ScanAsMap
func ScanAsMap(stmnt *Stmt) (map[string]string, error) {
temp_result := make([]string, Columns(stmnt))
addrs := make([]interface{}, Columns(stmnt))
for i := range temp_result {
addrs[i] = &temp_result[i]
}
err := stmnt.Scan(addrs...)
if err != nil {
return nil, err
}
result := map[string]string{}
for i, v := range temp_result {
result[C.GoString(C.sqlite3_column_name(stmnt.stmt, C.int(i)))] = v
}
return result, nil
}
示例7: Name
func (c ResultColumn) Name(s *Statement) string {
return C.GoString(C.sqlite3_column_name(s.cptr, C.int(c)))
}
示例8: ColumnName
func (s *Statement) ColumnName(column int) (name string) {
cname := C.sqlite3_column_name(s.cptr, C.int(column))
name = C.GoString(cname)
return
}
示例9: ColumnName
// ColumnName returns the name of the Nth column of the result set returned by the SQL statement. (not cached)
// The leftmost column is number 0.
// (See http://sqlite.org/c3ref/column_name.html)
func (s *Stmt) ColumnName(index int) string {
// If there is no AS clause then the name of the column is unspecified and may change from one release of SQLite to the next.
return C.GoString(C.sqlite3_column_name(s.stmt, C.int(index)))
}
示例10: ColumnName
func (s *Stmt) ColumnName(n int) string {
return C.GoString(C.sqlite3_column_name(s.stmt, C.int(n)))
}