/lua-mysql-1

MySQL 5.5 access for Lua 5.3

Primary LanguageCApache License 2.0Apache-2.0

lua-mysql

lua-mysql is a simple(but not complete) Lua 5.3 binding of MySQL 5.5 C API

Installation

First obtain premake5, then a C99 compiler and libmysqlclient library is needed.

Build on Windows 7 x64

  1. Type premake5 vs2013 on command window to generate Visual C++ solution files.
  2. Use Visual Studio 2013(either Ultimate or Community version) to compile executable binary.
  3. Pre-compiled Windows x86/64 libmysql binary can be obtained here

Build on Ubuntu 14.04 64-bit

  1. Type sudo apt-get install libmysqlclient-dev
  2. Type premake5 gmake && make config=release

Usage at a glance

local mysql = require 'luamysql'
local client = mysql.new_client()
client:connect{host = 'localhost', user = 'root', passwd = 'mypwd', db = 'test'}
local cur = client:execute('select * from test')
while true do
     local r = cur:fetch()
     for k, v in ipairs(r) do
        print(k, v)
     end
end

See more exampes and API doc