You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A native Go implementation of SQL client for the GopherLua VM.
Using
Loading Modules
import (
"github.com/tengattack/gluasql"
)
// Bring up a GopherLua VML:=lua.NewState()
deferL.Close()
// Preload LuaSql modulesgluasql.Preload(L)
Or if we only need mysql module:
import (
mysql "github.com/tengattack/gluasql/mysql"
)
// Bring up a GopherLua VML:=lua.NewState()
deferL.Close()
L.PreloadModule("mysql", mysql.Loader)
MySQL
mysql=require('mysql')
c=mysql.new()
ok, err=c:connect({ host='127.0.0.1', port=3306, database='test', user='user', password='pass' })
ifokthenres, err=c:query('SELECT * FROM mytable LIMIT 2')
dump(res)
end
sqlite3=require('sqlite3')
c=sqlite3.new()
ok, err=c:open('test.db', { cache='shared' })
ifokthenres, err=c:query('SELECT * FROM mytable LIMIT 2')
dump(res)
end
Testing
$ go test -coverprofile=/tmp/go-code-cover github.com/tengattack/gluasql...
ok github.com/tengattack/gluasql/mysql 0.020s coverage: 79.9% of statements
ok github.com/tengattack/gluasql/sqlite3 0.019s coverage: 71.3% of statements
ok github.com/tengattack/gluasql/util 0.015s coverage: 76.9% of statements
License
MIT
About
A native Go implementation of SQL client for the GopherLua VM.