Skip to content
Luvit port of node-mysql
Lua
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
deps
.gitmodules travis Feb 14, 2012
.travis.yml travis Feb 14, 2012
LICENSE.txt add license text Feb 14, 2012
Makefile delete deps on libluajit Mar 19, 2012
README.md update licenses Feb 14, 2012
auth.lua update licenses Feb 14, 2012
client.lua update licenses Feb 14, 2012
constants.lua update licenses Feb 14, 2012
mysql.lua update licenses Feb 14, 2012
outgoing_packet.lua update licenses Feb 14, 2012
parser.lua omit assert on greeting_2 Jan 7, 2013
query.lua update licenses Feb 14, 2012
sha1.lua handshake worked Feb 13, 2012
test.lua travis test continued Feb 14, 2012
util.lua update licenses Feb 14, 2012

README.md

Luvit port of node-mysql

Luvit port of node-mysql .

Much code is from node-mysql JavaScript source. Thank for former work!

Example

local MySQL = require( "./mysql" )

local client = MySQL.createClient( { database="test",user="passtestuser",port=3306,password="hoge", logfunc=nil } )

client:query( "CREATE DATABASE luvit_mysql_testdb", function(err)
    if err and err.number ~= MySQL.ERROR_DB_CREATE_EXISTS then
      error("cannot create db" )
    end
  end)

client:query( "USE luvit_mysql_testdb" )

client:query( "DROP TABLE IF EXISTS testtable", function(err,res,fields)
    assert(not err)
  end)

client:query( "CREATE TABLE testtable (id INT(11) AUTO_INCREMENT, name VARCHAR(255), age INT(11), created DATETIME, PRIMARY KEY (id) )",
  function(err,res,fields)
    assert( not err )
    client:query( "INSERT INTO testtable SET name = 'ken', age = 40, created=now()",
      function(err)
        assert( not err )
      end)
    client:query( "SELECT * FROM testtable", function(err,res,fields)
        print(fields.name.fieldType, MySQL.FIELD_TYPE_VAR_STRING)
        for i,v in ipairs(res) do
          print(v.id, v.name, v.age, v.created.year, v.created.month, v.created.day )
        end
      end)
  end)

HowTo

shell> luvit test.lua

TODO

  • support luvit's module system
You can’t perform that action at this time.