Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gosqlite
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gosqlite
Commits
6bcd838f
Commit
6bcd838f
authored
Nov 26, 2011
by
gwenn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Scan support interface{} pointer (useful when sqlite data type is dynamic).
parent
3dd0fe33
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
8 deletions
+17
-8
README
README
+1
-1
driver.go
driver.go
+1
-6
example_test.go
example_test.go
+2
-0
sqlite.go
sqlite.go
+13
-1
No files found.
README
View file @
6bcd838f
...
...
@@ -37,7 +37,7 @@ Conn#EnableLoadExtension/LoadExtension
Stmt#ExecUpdate
Stmt#BindParameterCount/BindParameterIndex/BindParameterName
Stmt#ClearBindings
Stmt#ColumnCount/ColumnIndex(name)/ColumnName(index)/ColumnType(index)
Stmt#ColumnCount/Column
Names/Column
Index(name)/ColumnName(index)/ColumnType(index)
Stmt#ReadOnly
Blob:
...
...
driver.go
View file @
6bcd838f
...
...
@@ -110,12 +110,7 @@ func (s *stmtImpl) Query(args []interface{}) (driver.Rows, error) {
// TODO Cache result?
func
(
s
*
stmtImpl
)
Columns
()
[]
string
{
count
:=
s
.
s
.
ColumnCount
()
cols
:=
make
([]
string
,
count
)
for
i
:=
0
;
i
<
count
;
i
++
{
cols
[
i
]
=
s
.
s
.
ColumnName
(
i
)
}
return
cols
return
s
.
s
.
ColumnNames
()
}
func
(
s
*
stmtImpl
)
Next
(
dest
[]
interface
{})
error
{
...
...
example_test.go
View file @
6bcd838f
...
...
@@ -15,6 +15,7 @@ func ExampleOpen() {
fmt
.
Printf
(
"%d
\n
"
,
db
.
TotalChanges
())
}
/*
// <nil>
func ExampleExec() {
db, _ := sqlite.Open(":memory:")
...
...
@@ -22,6 +23,7 @@ func ExampleExec() {
err := db.Exec("CREATE TABLE test(id INTEGER PRIMARY KEY NOT NULL, name TEXT NOT NULL)")
fmt.Println(err)
}
*/
// true <nil>
func
ExamplePrepare
()
{
...
...
sqlite.go
View file @
6bcd838f
...
...
@@ -536,6 +536,15 @@ func (s *Stmt) ColumnName(index int) string {
return
C
.
GoString
(
C
.
sqlite3_column_name
(
s
.
stmt
,
C
.
int
(
index
)))
}
func
(
s
*
Stmt
)
ColumnNames
()
[]
string
{
count
:=
s
.
ColumnCount
()
names
:=
make
([]
string
,
count
)
for
i
:=
0
;
i
<
count
;
i
++
{
names
[
i
]
=
s
.
ColumnName
(
i
)
}
return
names
}
type
Type
int
func
(
t
Type
)
String
()
string
{
...
...
@@ -668,6 +677,9 @@ func (s *Stmt) ScanColumn(index int, value interface{}) (bool, error) {
*
value
,
isNull
,
err
=
s
.
ScanFloat64
(
index
)
case
*
[]
byte
:
*
value
,
isNull
,
err
=
s
.
ScanBlob
(
index
)
case
*
interface
{}
:
*
value
=
s
.
ScanValue
(
index
)
isNull
=
*
value
==
nil
default
:
return
false
,
errors
.
New
(
"unsupported type in Scan: "
+
reflect
.
TypeOf
(
value
)
.
String
())
}
...
...
@@ -875,7 +887,7 @@ func (c *Conn) Close() error {
// Dangling statements
stmt
:=
C
.
sqlite3_next_stmt
(
c
.
db
,
nil
)
for
stmt
!=
nil
{
//Log(
1, "Dangling statement")
Log
(
2
1
,
"Dangling statement"
)
C
.
sqlite3_finalize
(
stmt
)
stmt
=
C
.
sqlite3_next_stmt
(
c
.
db
,
stmt
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment