コード例 #1
0
ファイル: driver.go プロジェクト: rsc/sqlite
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
0
ファイル: stmt.go プロジェクト: brandondyck/gosqlite
// 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
0
ファイル: sqlite.go プロジェクト: kazyk/go-sqlite
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
0
ファイル: sqlite3.go プロジェクト: Wishing-Wall/wishingwall
// 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
0
ファイル: sqlite3.go プロジェクト: gidden/cloudlus
// 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
0
ファイル: extra.go プロジェクト: richard-lyman/gosqlite
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
0
ファイル: result_column.go プロジェクト: rwj/gosqlite3
func (c ResultColumn) Name(s *Statement) string {
	return C.GoString(C.sqlite3_column_name(s.cptr, C.int(c)))
}
コード例 #8
0
ファイル: sqlite3.go プロジェクト: cskau/gosqlite3
func (s *Statement) ColumnName(column int) (name string) {
	cname := C.sqlite3_column_name(s.cptr, C.int(column))
	name = C.GoString(cname)
	return
}
コード例 #9
0
ファイル: stmt.go プロジェクト: pkf/gosqlite
// 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
0
ファイル: sqlite.go プロジェクト: aganno2/gosqlite
func (s *Stmt) ColumnName(n int) string {
	return C.GoString(C.sqlite3_column_name(s.stmt, C.int(n)))
}