作者:rs
项目:sqlit
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
}
作者:brandondyc
项目:gosqlit
// 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)))
}
作者:kazy
项目:go-sqlit
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
}
作者:Wishing-Wal
项目:wishingwal
// 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
}
作者:gidde
项目:cloudlu
// 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
}
作者:richard-lyma
项目:gosqlit
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
}
作者:rw
项目:gosqlite
func (c ResultColumn) Name(s *Statement) string {
return C.GoString(C.sqlite3_column_name(s.cptr, C.int(c)))
}
作者:cska
项目:gosqlite
func (s *Statement) ColumnName(column int) (name string) {
cname := C.sqlite3_column_name(s.cptr, C.int(column))
name = C.GoString(cname)
return
}
作者:pk
项目:gosqlit
// 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)))
}
作者:aganno
项目:gosqlit
func (s *Stmt) ColumnName(n int) string {
return C.GoString(C.sqlite3_column_name(s.stmt, C.int(n)))
}