Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Luvit port of node-mysql
Lua
branch: master
Failed to load latest commit information.
deps luvit 0.1.5 to 0.2
.gitmodules travis
.travis.yml travis
LICENSE.txt add license text
Makefile delete deps on libluajit
README.md update licenses
auth.lua update licenses
client.lua update licenses
constants.lua update licenses
mysql.lua update licenses
outgoing_packet.lua update licenses
parser.lua omit assert on greeting_2
query.lua update licenses
sha1.lua handshake worked
test.lua travis test continued
util.lua update licenses

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
Something went wrong with that request. Please try again.