Commit 6393481f authored by gwenn's avatar gwenn

Improves README file and fix issue #1.

parent 26e4aa2d
...@@ -4,25 +4,27 @@ Yet another SQLite binding based on: ...@@ -4,25 +4,27 @@ Yet another SQLite binding based on:
This binding implements the "database/sql/driver" interface. This binding implements the "database/sql/driver" interface.
See [package documentation](http://go.pkgdoc.org/github.com/gwenn/gosqlite). See [package documentation](http://godoc.org/github.com/gwenn/gosqlite).
[![Build Status][1]][2] [![Build Status][1]][2]
[1]: https://secure.travis-ci.org/gwenn/gosqlite.png [1]: https://secure.travis-ci.org/gwenn/gosqlite.png
[2]: http://www.travis-ci.org/gwenn/gosqlite [2]: http://www.travis-ci.org/gwenn/gosqlite
### Changes:
Open supports flags. Open supports flags.
Conn#Exec handles multiple statements (separated by semicolons) properly. Conn.Exec handles multiple statements (separated by semicolons) properly.
Conn#Prepare can optionnaly #Bind as well. Conn.Prepare can optionnaly bind as well.
Conn#Prepare can reuse already prepared Stmt. Conn.Prepare can reuse already prepared Stmt.
Conn#Close ensures that all dangling statements are finalized. Conn.Close ensures that all dangling statements are finalized.
Stmt#Exec is renamed in Stmt#Bind and a new Stmt#Exec method is introduced to #Bind and #Step. Stmt.Exec is renamed in Stmt.Bind and a new Stmt.Exec method is introduced to bind and step.
Stmt#Bind uses native sqlite3_bind_x methods and failed if unsupported type. Stmt.Bind uses native sqlite3_bind_x methods and failed if unsupported type.
Stmt#NamedBind can be used to bind by name. Stmt.NamedBind can be used to bind by name.
Stmt#Next returns a (bool, os.Error) couple like Reader#Read. Stmt.Next returns a (bool, os.Error) couple like Reader.Read.
Stmt#Scan uses native sqlite3_column_x methods. Stmt.Scan uses native sqlite3_column_x methods.
Stmt#NamedScan is added. It's compliant with [go-dbi](https://github.com/thomaslee/go-dbi/). Stmt.NamedScan is added. It's compliant with [go-dbi](https://github.com/thomaslee/go-dbi/).
Stmt#ScanByIndex/ScanByName are added to test NULL value. Stmt.ScanByIndex/ScanByName are added to test NULL value.
Currently, the weak point of the binding is the *Scan* methods: Currently, the weak point of the binding is the *Scan* methods:
The original implementation is using this strategy: The original implementation is using this strategy:
...@@ -44,38 +46,39 @@ SQLite logs (SQLITE_CONFIG_LOG) can be activated by: ...@@ -44,38 +46,39 @@ SQLite logs (SQLITE_CONFIG_LOG) can be activated by:
https://github.com/mattn/go-sqlite3 (Nov 11, 2011) https://github.com/mattn/go-sqlite3 (Nov 11, 2011)
https://code.google.com/p/go-sqlite (Feb 12, 2013) https://code.google.com/p/go-sqlite (Feb 12, 2013)
### Misc: ### Additions:
Conn#Exists
Conn#OneValue Conn.Exists
Conn.OneValue
Conn#OpenVfs
Conn#EnableFkey/IsFKeyEnabled Conn.OpenVfs
Conn#Changes/TotalChanges Conn.EnableFkey/IsFKeyEnabled
Conn#LastInsertRowid Conn.Changes/TotalChanges
Conn#Interrupt Conn.LastInsertRowid
Conn#Begin/BeginTransaction(type)/Commit/Rollback Conn.Interrupt
Conn#GetAutocommit Conn.Begin/BeginTransaction(type)/Commit/Rollback
Conn#EnableLoadExtension/LoadExtension Conn.GetAutocommit
Conn#IntegrityCheck Conn.EnableLoadExtension/LoadExtension
Conn.IntegrityCheck
Stmt#Insert/ExecDml/Select/SelectOneRow
Stmt#BindParameterCount/BindParameterIndex(name)/BindParameterName(index) Stmt.Insert/ExecDml/Select/SelectOneRow
Stmt#ClearBindings Stmt.BindParameterCount/BindParameterIndex(name)/BindParameterName(index)
Stmt#ColumnCount/ColumnNames/ColumnIndex(name)/ColumnName(index)/ColumnType(index) Stmt.ClearBindings
Stmt#ReadOnly Stmt.ColumnCount/ColumnNames/ColumnIndex(name)/ColumnName(index)/ColumnType(index)
Stmt#Busy Stmt.ReadOnly
Stmt.Busy
Blob: Blob:
ZeroBlobLength ZeroBlobLength
Conn#NewBlobReader Conn.NewBlobReader
Conn#NewBlobReadWriter Conn.NewBlobReadWriter
Meta: Meta:
Conn#Databases Conn.Databases
Conn#Tables Conn.Tables
Conn#Columns Conn.Columns
Conn#ForeignKeys Conn.ForeignKeys
Conn#Indexes/IndexColumns Conn.Indexes/IndexColumns
Time: Time:
JulianDay JulianDay
...@@ -83,28 +86,32 @@ JulianDayToUTC ...@@ -83,28 +86,32 @@ JulianDayToUTC
JulianDayToLocalTime JulianDayToLocalTime
Trace: Trace:
Conn#BusyHandler Conn.BusyHandler
Conn#Profile Conn.Profile
Conn#ProgressHandler Conn.ProgressHandler
Conn#SetAuthorizer Conn.SetAuthorizer
Conn#Trace Conn.Trace
Stmt#Status Stmt.Status
Hook: Hook:
Conn#CommitHook Conn.CommitHook
Conn#RollbackHook Conn.RollbackHook
Conn#UpdateHook Conn.UpdateHook
Function: Function:
Conn#CreateScalarFunction Conn.CreateScalarFunction
Conn#CreateAggregateFunction Conn.CreateAggregateFunction
Virtual Table (partial support):
Conn.CreateModule
Conn.DeclareVTab
### GC: ### GC:
Although Go is gced, there is no destructor (see http://www.airs.com/blog/archives/362). Although Go is gced, there is no destructor (see http://www.airs.com/blog/archives/362).
In the gosqlite wrapper, no finalizer is used. In the gosqlite wrapper, no finalizer is used.
So users must ensure that C ressources (database connections, prepared statements, BLOBs, Backups) are destroyed/deallocated by calling Conn#Close, Stmt#Finalize, BlobReader#Close, Backup#Close. So users must ensure that C ressources (database connections, prepared statements, BLOBs, Backups) are destroyed/deallocated by calling Conn.Close, Stmt.Finalize, BlobReader.Close, Backup.Close.
Therefore, sqlite3_close/sqlite3_next_stmt are used by Conn#Close to free the database connection and all dangling statements (not sqlite3_close_v2) (see http://sqlite.org/c3ref/close.html). Therefore, sqlite3_close/sqlite3_next_stmt are used by Conn.Close to free the database connection and all dangling statements (not sqlite3_close_v2) (see http://sqlite.org/c3ref/close.html).
### Benchmarks: ### Benchmarks:
$ go test -bench . -benchmem $ go test -bench . -benchmem
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment