ericdai / luadbi Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/luadbi
License: MIT License
Automatically exported from code.google.com/p/luadbi
License: MIT License
Please visit http://code.google.com/p/luadbi/w/list for details on using LuaDBI
Building OSX binaries is not easy. Does anyone have 32/64 bit Intel binaries
ready for download (mysql, postgre, sqlite)?
Original issue reported on code.google.com by [email protected]
on 24 Jan 2013 at 2:29
patching file Makefile
mkdir -p build
gcc -c -o build/dbd_common.o dbd/common.c -g -pedantic -Wall -O2 -shared -fpic
-I /usr/include/lua5.1 -I /usr/include/mysql -I
/usr/include/postgresql/internal -I /opt/ibm/db2exc/V9.5/include/ -I
/usr/lib/oracle/xe/app/oracle/product/10.2.0/client/rdbms/public/ -I .
gcc -c -o build/dbd_mysql_main.o dbd/mysql/main.c -g -pedantic -Wall -O2
-shared -fpic -I /usr/include/lua5.1 -I /usr/include/mysql -I
/usr/include/postgresql/internal -I /opt/ibm/db2exc/V9.5/include/ -I
/usr/lib/oracle/xe/app/oracle/product/10.2.0/client/rdbms/public/ -I .
In file included from /usr/include/mysql/mysql.h:71:0,
from dbd/mysql/dbd_mysql.h:6,
from dbd/mysql/main.c:1:
/usr/include/mysql/mysql_version.h:1:1: warning: null character(s) ignored
[enabled by default]
In file included from /usr/include/mysql/mysql.h:72:0,
from dbd/mysql/dbd_mysql.h:6,
from dbd/mysql/main.c:1:
/usr/include/mysql/mysql_com.h:1:30: error: expected ')' before '*' token
/usr/include/mysql/mysql_com.h:52:2: warning: ISO C does not allow extra ';'
outside of a function [-pedantic]
/usr/include/mysql/mysql_com.h:550:2: error: #endif without #if
/usr/include/mysql/mysql_com.h:551:1: warning: null character(s) ignored
[enabled by default]
In file included from /usr/include/mysql/mysql.h:73:0,
from dbd/mysql/dbd_mysql.h:6,
from dbd/mysql/main.c:1:
/usr/include/mysql/mysql_time.h:1:1: warning: data definition has no type or
storage class [enabled by default]
/usr/include/mysql/mysql_time.h:1:1: warning: type defaults to 'int' in
declaration of 'type' [-Wimplicit-int]
/usr/include/mysql/mysql_time.h:2:1: error: expected identifier or '(' before
'}' token
/usr/include/mysql/mysql_time.h:2:3: warning: data definition has no type or
storage class [enabled by default]
/usr/include/mysql/mysql_time.h:2:3: warning: type defaults to 'int' in
declaration of 'MYSQL_TIME' [-Wimplicit-int]
/usr/include/mysql/mysql_time.h:4:2: error: #endif without #if
/usr/include/mysql/mysql_time.h:5:1: warning: null character(s) ignored
[enabled by default]
In file included from /usr/include/mysql/mysql.h:73:0,
from dbd/mysql/dbd_mysql.h:6,
from dbd/mysql/main.c:1:
/usr/include/mysql/mysql_time.h:5:0: error: unterminated #ifndef
In file included from dbd/mysql/dbd_mysql.h:6:0,
from dbd/mysql/main.c:1:
/usr/include/mysql/mysql.h:127:23: warning: ISO C90 does not support 'long
long' [-Wlong-long]
In file included from /usr/include/mysql/mysql.h:131:0,
from dbd/mysql/dbd_mysql.h:6,
from dbd/mysql/main.c:1:
/usr/include/mysql/typelib.h:2:43: error: unknown type name 'TYPELIB'
/usr/include/mysql/typelib.h:3:45: error: unknown type name 'TYPELIB'
/usr/include/mysql/typelib.h:15:1: error: unknown type name 'TYPELIB'
/usr/include/mysql/typelib.h:16:48: error: unknown type name 'TYPELIB'
/usr/include/mysql/typelib.h:17:29: error: unknown type name 'TYPELIB'
/usr/include/mysql/typelib.h:18:1: error: unknown type name 'TYPELIB'
/usr/include/mysql/typelib.h:18:30: error: unknown type name 'MEM_ROOT'
/usr/include/mysql/typelib.h:18:46: error: unknown type name 'TYPELIB'
/usr/include/mysql/typelib.h:20:1: error: unknown type name 'TYPELIB'
/usr/include/mysql/typelib.h:22:1: error: unknown type name 'TYPELIB'
/usr/include/mysql/typelib.h:27:2: error: #endif without #if
/usr/include/mysql/typelib.h:28:1: warning: null character(s) ignored [enabled
by default]
In file included from /usr/include/mysql/mysql.h:146:0,
from dbd/mysql/dbd_mysql.h:6,
from dbd/mysql/main.c:1:
/usr/include/mysql/my_alloc.h:1:5: error: expected '=', ',', ';', 'asm' or
'__attribute__' before 'for'
/usr/include/mysql/my_alloc.h:5:1: error: expected identifier or '(' before '}'
token
/usr/include/mysql/my_alloc.h:5:3: warning: data definition has no type or
storage class [enabled by default]
/usr/include/mysql/my_alloc.h:5:3: warning: type defaults to 'int' in
declaration of 'USED_MEM' [-Wimplicit-int]
/usr/include/mysql/my_alloc.h:10:3: error: expected specifier-qualifier-list
before 'USED_MEM'
/usr/include/mysql/my_alloc.h:8:16: warning: struct has no members [-pedantic]
/usr/include/mysql/my_alloc.h:30:2: error: #endif without #if
/usr/include/mysql/my_alloc.h:31:1: warning: null character(s) ignored [enabled
by default]
make: *** [build/dbd_mysql_main.o] Error 1
Original issue reported on code.google.com by [email protected]
on 14 Nov 2012 at 10:17
Please include a LICENSE/COPYING file containing the appropriate license. This
helps
users, packagers, and various automated tools... in addition to removing any
ambiguity as to
what license applies to the code.
You can find a template for MIT here:
http://www.opensource.org/licenses/mit-license.php
Original issue reported on code.google.com by MWild1
on 25 May 2010 at 5:09
Running this code:
local dbi = require('DBI')
local db = assert(dbi.Connect("MySQL", "test", "root", "", "localhost", 3306))
local sth = assert(db:prepare('SELECT 1 as id;'))
sth:execute()
row = sth:fetch(true)
print(row.id)
sth:close()
db:close()
I would expect to see `1` in the console. Instead, I see some float number like
`4.9406564584125e-324`
This is a problem because when you try to retrieve the id of the latest
inserted record with the query `SELECT LAST_INSERT_ID() as id`, you won't be
able to.
Original issue reported on code.google.com by [email protected]
on 10 Nov 2013 at 4:36
What are the steps to install this in a "Lua 4 Windows" environment? I tried
copying DBI.lua to the \lua\lua and the DLLs to \lua\clibs, but when i tried to
use it, got complaints about several missing DLLs.
Thanks,
glauber
Original issue reported on code.google.com by [email protected]
on 21 Oct 2010 at 8:27
What steps will reproduce the problem?
do the following in a loop:
1. local sth = dbh:prepare(sql)
2. sth:execute(...)
3. sth:fetch()
4. collectgarbage()
What is the expected output? What do you see instead?
the statement handles aren't being garbage collected and process vm size
grows, unless sth:close() is called explicitly
What version of the product are you using? On what operating system?
0.4 on Lua 5.1.4 (Linux)
Please provide any additional information below.
I'm digging around looking for what's holding references to the statement
handle udata, if I find it I'll submit a patch for review
Original issue reported on code.google.com by [email protected]
on 21 Apr 2010 at 5:33
patching file Makefile
mkdir -p build
gcc -c -o build/dbd_common.o dbd/common.c -g -pedantic -Wall -O2 -shared -fpic
-I /usr/include/lua5.1 -I /usr/include/mysql -I
/usr/include/postgresql/internal -I /opt/ibm/db2exc/V9.5/include/ -I
/usr/lib/oracle/xe/app/oracle/product/10.2.0/client/rdbms/public/ -I .
gcc -c -o build/dbd_mysql_main.o dbd/mysql/main.c -g -pedantic -Wall -O2
-shared -fpic -I /usr/include/lua5.1 -I /usr/include/mysql -I
/usr/include/postgresql/internal -I /opt/ibm/db2exc/V9.5/include/ -I
/usr/lib/oracle/xe/app/oracle/product/10.2.0/client/rdbms/public/ -I .
In file included from /usr/include/mysql/mysql.h:71:0,
from dbd/mysql/dbd_mysql.h:6,
from dbd/mysql/main.c:1:
/usr/include/mysql/mysql_version.h:1:1: warning: null character(s) ignored
[enabled by default]
In file included from /usr/include/mysql/mysql.h:72:0,
from dbd/mysql/dbd_mysql.h:6,
from dbd/mysql/main.c:1:
/usr/include/mysql/mysql_com.h:1:30: error: expected ')' before '*' token
/usr/include/mysql/mysql_com.h:52:2: warning: ISO C does not allow extra ';'
outside of a function [-pedantic]
/usr/include/mysql/mysql_com.h:550:2: error: #endif without #if
/usr/include/mysql/mysql_com.h:551:1: warning: null character(s) ignored
[enabled by default]
In file included from /usr/include/mysql/mysql.h:73:0,
from dbd/mysql/dbd_mysql.h:6,
from dbd/mysql/main.c:1:
/usr/include/mysql/mysql_time.h:1:1: warning: data definition has no type or
storage class [enabled by default]
/usr/include/mysql/mysql_time.h:1:1: warning: type defaults to 'int' in
declaration of 'type' [-Wimplicit-int]
/usr/include/mysql/mysql_time.h:2:1: error: expected identifier or '(' before
'}' token
/usr/include/mysql/mysql_time.h:2:3: warning: data definition has no type or
storage class [enabled by default]
/usr/include/mysql/mysql_time.h:2:3: warning: type defaults to 'int' in
declaration of 'MYSQL_TIME' [-Wimplicit-int]
/usr/include/mysql/mysql_time.h:4:2: error: #endif without #if
/usr/include/mysql/mysql_time.h:5:1: warning: null character(s) ignored
[enabled by default]
In file included from /usr/include/mysql/mysql.h:73:0,
from dbd/mysql/dbd_mysql.h:6,
from dbd/mysql/main.c:1:
/usr/include/mysql/mysql_time.h:5:0: error: unterminated #ifndef
In file included from dbd/mysql/dbd_mysql.h:6:0,
from dbd/mysql/main.c:1:
/usr/include/mysql/mysql.h:127:23: warning: ISO C90 does not support 'long
long' [-Wlong-long]
In file included from /usr/include/mysql/mysql.h:131:0,
from dbd/mysql/dbd_mysql.h:6,
from dbd/mysql/main.c:1:
/usr/include/mysql/typelib.h:2:43: error: unknown type name 'TYPELIB'
/usr/include/mysql/typelib.h:3:45: error: unknown type name 'TYPELIB'
/usr/include/mysql/typelib.h:15:1: error: unknown type name 'TYPELIB'
/usr/include/mysql/typelib.h:16:48: error: unknown type name 'TYPELIB'
/usr/include/mysql/typelib.h:17:29: error: unknown type name 'TYPELIB'
/usr/include/mysql/typelib.h:18:1: error: unknown type name 'TYPELIB'
/usr/include/mysql/typelib.h:18:30: error: unknown type name 'MEM_ROOT'
/usr/include/mysql/typelib.h:18:46: error: unknown type name 'TYPELIB'
/usr/include/mysql/typelib.h:20:1: error: unknown type name 'TYPELIB'
/usr/include/mysql/typelib.h:22:1: error: unknown type name 'TYPELIB'
/usr/include/mysql/typelib.h:27:2: error: #endif without #if
/usr/include/mysql/typelib.h:28:1: warning: null character(s) ignored [enabled
by default]
In file included from /usr/include/mysql/mysql.h:146:0,
from dbd/mysql/dbd_mysql.h:6,
from dbd/mysql/main.c:1:
/usr/include/mysql/my_alloc.h:1:5: error: expected '=', ',', ';', 'asm' or
'__attribute__' before 'for'
/usr/include/mysql/my_alloc.h:5:1: error: expected identifier or '(' before '}'
token
/usr/include/mysql/my_alloc.h:5:3: warning: data definition has no type or
storage class [enabled by default]
/usr/include/mysql/my_alloc.h:5:3: warning: type defaults to 'int' in
declaration of 'USED_MEM' [-Wimplicit-int]
/usr/include/mysql/my_alloc.h:10:3: error: expected specifier-qualifier-list
before 'USED_MEM'
/usr/include/mysql/my_alloc.h:8:16: warning: struct has no members [-pedantic]
/usr/include/mysql/my_alloc.h:30:2: error: #endif without #if
/usr/include/mysql/my_alloc.h:31:1: warning: null character(s) ignored [enabled
by default]
make: *** [build/dbd_mysql_main.o] Error 1
Original issue reported on code.google.com by [email protected]
on 14 Nov 2012 at 10:14
What steps will reproduce the problem?
1. local userSelect = assert(Server.db:prepare('SELECT user_id, password,
username FROM user WHERE username = ?'))
2. userSelect:execute(currentusername);
3. local row = userSelect:fetch();
What is the expected output? What do you see instead?
The expected output is the md5hash for the user's password.
This hash is received successfully, but there often are (about half the time)
trailing characters out of nowhere - this is most likely a allocation issue?
The added strings are e.g.
</)
tion)
bin")
6g="b)
What version of the product are you using? On what operating system?
Lua 5.1.4, luadbi 0.5-1, luadbi-mysql 0.5-1, luasql-mysql 2.3.0-1
Please provide any additional information below.
If you need any further information please let me know!
Original issue reported on code.google.com by [email protected]
on 6 Mar 2013 at 9:24
I spent some time messing with the Debian luadbi package trying to get it work
with LUA 5.2 before I realised that this work had already been performed
recently. I arrived at a similar solution to the issue but there are a couple
of advantages to the way I did it that could be useful to apply.
Firstly, I have factored out the code that is used to register the LUA for
connection and statement objects into a single function. This means any
further changes can be made in one place.
Secondly, I have amended the registration code to no longer create global
variables or pollute the package.loaded table. This also allows the Connect
method to be simplified and not contain conditional code based on the LUA
version.
I have tested this with LUA 5.1 and LUA 5.2 against SQLite3 and DB2 and it is
working nicely for me. However, please note that I have never used the LUA C
API before this week so there may be subtle problems with the code I haven't
noticed.
I thought it was worth sharing though.
Original issue reported on code.google.com by [email protected]
on 14 Jun 2015 at 5:19
Attachments:
You need to realize not everyone is going to have the same configuration as you
and that most people are dumb. Please create an autoconf system or at least
explain in the read me about library and include paths. You should have liblua
as a library for this as it won't build without it.
COMMON_LDFLAGS=-llua
That's all I did, and I had to change/add a few of the header include paths and
library include paths. Most people cannot do this. You could also autodetect
where lua modules are installed.
If you need help figuring out how to do so, try Google and look at examples of
other lua modules.
Original issue reported on code.google.com by [email protected]
on 7 Jan 2012 at 1:40
What steps will reproduce the problem?
1. Insert a string with a null character ("\000") into a blob field.
2. Check the database.
What is the expected output? What do you see instead?
I expect the full string, but I get the string until the first null character.
Attached patch fixes this issue.
Original issue reported on code.google.com by [email protected]
on 22 Sep 2013 at 10:20
What steps will reproduce the problem?
1. CREATE table with a BIGINT column.
2. INSERT 1 into this column
3. SELECT * from table
What is the expected output? What do you see instead?
Expexted output is the same as input: 1
What I see is 4.9406564584125e-324.
What version of the product are you using? On what operating system?
luadbi-mysql 0.5.
MySQL server 5.1.71 and 5.5.38.
Operating systems Ubuntu, FreeBSD, OpenWrt.
Please provide any additional information below.
I think that luadbi-mysql is handling an int like a double.
If I try to read the same table with MySQL-cli, luasql-mysql or Python-MySQLdb
everything is shown as expected.
The root cause is probably the same as for issue #26.
Best regards,
Peter Fassberg
Sweden
Original issue reported on code.google.com by [email protected]
on 30 Jun 2014 at 9:47
Basically LuaDBI will read characters like İ as ? and Ç as ▒, when getting
results after executing a query.
Original issue reported on code.google.com by [email protected]
on 21 Aug 2013 at 10:42
See below
/*
* allocate a new string for the converted SQL statement
*/
newsql = (char *)malloc(sizeof(char) * (len+extra_space+1));
memset(newsql, 0, sizeof(char) * (len+extra_space+1));
Original issue reported on code.google.com by [email protected]
on 23 Jan 2014 at 5:14
What steps will reproduce the problem?
1. Create a table with an blob column
2. SELECT blobcolumn FROM sometable
3. You got an infinite loop :(
What is the expected output? What do you see instead?
return just and empty string
What version of the product are you using? On what operating system?
0.5 in Linux
Original issue reported on code.google.com by [email protected]
on 27 May 2012 at 3:31
I got some gap like "ØîxÑ6" or partical content of an varchar field if i
fetch an enum field with lua-dbi
lua-dbi-0.5-2,lua-5.1.4-4,mysql-5.1.69,mysql-5.1.69 server,CentOS 6.4 64bit
mysql> describe dp_public;
+--------------------+-----------------------------+------+-----+----------+----
------------+
| Field | Type | Null | Key | Default |
Extra |
+--------------------+-----------------------------+------+-----+----------+----
------------+
| id | int(10) | NO | PRI | NULL |
auto_increment |
| destination_number | varchar(64) | NO | | |
|
| direction | enum('internal','external') | NO | | internal |
|
| bridge | varchar(64) | NO | | |
|
+--------------------+-----------------------------+------+-----+----------+----
------------+
mysql> select * from dp_public;
+----+--------------------+-----------+---------------+
| id | destination_number | direction | bridge |
+----+--------------------+-----------+---------------+
| 4 | playrand | internal | 172.20.120.76 |
+----+--------------------+-----------+---------------+
-- Logging
LOGLEVEL = "info"
-- Progname
PROGNAME = "doit.lua"
-- functions
function logger(message)
print(LOGLEVEL,"["..PROGNAME.."] "..message.."\n")
end
function mysqldp(u)
if u == nil then
return
end
local dbh = assert(DBI.Connect('MySQL', mydb, myuser, mypass, myhost))
--local sth = assert(dbh:prepare('SELECT `id`, `direction`, `bridge` FROM `dp_public` WHERE id=4 LIMIT 1'))
local sth = assert(dbh:prepare('SELECT `direction` FROM `dp_public` WHERE id=4 LIMIT 1'))
sth:execute()
row = sth:fetch ({}, "a")
if not row then
return
end
logger("row.direction " ..row.direction)
id = row.id
direction = row.direction
destination_number = row.destination_number
target = row.bridge
logger("direction "..direction)
dbh:close()
sth:close()
return id,destination_number,direction,target
end
number='playrand'
mysqldp(number)
lua doit.lua
info [sqluser.lua] row.direction internalØîxÑ6
info [sqluser.lua] direction internalØîxÑ6
Original issue reported on code.google.com by [email protected]
on 3 Jun 2013 at 1:40
mysql now supports unix socket, postgresql already has as you can see here:
http://www.postgresql.org/docs/8.3/static/libpq-connect.html (not tested)
test:
local db = require 'DBI'
local con = assert(db.Connect('MySQL', 'tupana', 'tupana', 'qX6MtLED',
'/tmp/mariadb.sock', nil))
Original issue reported on code.google.com by [email protected]
on 8 Feb 2014 at 6:09
Attachments:
What steps will reproduce the problem?
1. wget luadbi...tar.gz
2. tar xfz luadbi...tar.gz
2. make
What is the expected output? What do you see instead?
I expected make to work
tom@math:~/luadbi$ make sqlite3
gcc -c -o build/dbd_common.o dbd/common.c -g -pedantic -Wall -O2 -shared -fpic
-I /usr/include/lua5.1 -I /usr/include/mysql -I /usr/include/postgresql/ -I
/opt/ibm/db2exc/V9.5/include/ -I
/usr/lib/oracle/xe/app/oracle/product/10.2.0/client/rdbms/public/ -I ./
Assembler messages:
Fatal error: can't create build/dbd_common.o: No such file or directory
What version of the product are you using? On what operating system?
0.4
Please provide any additional information below.
mkdir build fixes it, but I'd expect the Makefile to accomplish this.
using ubuntu 10.04
Original issue reported on code.google.com by [email protected]
on 17 Jul 2010 at 5:10
Here are some improvements to makefile:
1) install support
2) destdir support
3) some kind of configuration support
So, it will fix #11 and #12, since it will be possible to add
PSQL_INC=-I/usr/include/postgresql/server
or
LUA_INC=-I/usr/include/luajit-2.0
and so on
Original issue reported on code.google.com by mva.name
on 12 May 2013 at 4:53
hello.
simple: working/build luadbi with Lua 5.2?
greetings
Original issue reported on code.google.com by sL1pKn07
on 16 Oct 2013 at 9:11
What steps will reproduce the problem?
1. Downloaded luadbi-0.5.0 and SQLite v.3.7.4
2. Put the .dll files in Lua/5.1/clibs/ and the DBI.lua in /Lua/5.1/lua/
3. Run the following Lua code:
<code>
require 'DBI'
local create_table = true
-- Create a connection
local dbh,err = assert(DBI.Connect('SQLite3', 'test.db'))
if not dbh then print(('could not do that: %s'):format(err)) end
-- Create a table
if create_table then
local suc, err = DBI.Do(dbh, 'CREATE TABLE "users1" ( "id" INTEGER NOT NULL, "name" TEXT NOT NULL, "email" TEXT NOT NULL, "password" TEXT NOT NULL, PRIMARY KEY ("id"));')
if not suc then print(('could not do that: %s'):format(err)) else print(('found %s'):format(suc)) end
end
-- Show available tables
local suc, err = DBI.Do(dbh, "SELECT name FROM sqlite_master WHERE type='table'
ORDER BY name;")
if not suc then print(('could not do that: %s'):format(err)) else print(('found
%s'):format(suc)) end
-- finish up
local ok = dbh:close()
</code>
What is the expected output? What do you see instead?
I was expecting the lines of the found tables. Didn't see any of them.
What version of the product are you using? On what operating system?
luadbi 0.5.0-win32, LuaforWindows 5.1.4-40, Windwos 7.
Please provide any additional information below.
The SQLite was downloaded from :
http://www.sqlite.org/sqlite-dll-win32-x86-3070400.zip
From what I can see with the dependancywalker the dbdsqlite3.dll is linking to
the C:\Program Files\...\Firefox\SQLite3.dll
Original issue reported on code.google.com by [email protected]
on 4 Jan 2011 at 6:44
What steps will reproduce the problem?
1. Download the zip release
2. Find no .dll libraries loadable by Lua.
What is the expected output? What do you see instead?
I expected to find dll files to load with Lua.
What version of the product are you using? On what operating system?
0.3
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 7 Sep 2009 at 3:13
I'm the Gentoo Linux maintainer for the luadbi package. Some of our users found
that luadbi doesn't correctly link with postgres on gentoo systems. Maybe you
can you look into fixing this. (Apparently the header can usually be found at
server/postgres_fe.h.)
More info: https://bugs.gentoo.org/show_bug.cgi?id=364141
Original issue reported on code.google.com by djc.ochtman
on 2 May 2011 at 4:20
What steps will reproduce the problem?
1. Extract a fresh copy of luadbi-0.4
2. Run 'make free'
3. Fatal error: can't create build/dbd_common.o: No such file or directory
What is the expected output? What do you see instead?
Fatal error: can't create build/dbd_common.o: No such file or directory
"mkdir build" fixes it.
What version of the product are you using? On what operating system?
0.4 on Ubuntu 10.04
Please provide any additional information below.
Thanks for luadbi :)
Original issue reported on code.google.com by MWild1
on 25 May 2010 at 2:25
Whilst testing my changes to the LUA object registration I decided to test with
DB2 (as I have a soft spot for DB2 as I used to use it a lot). I noticed the
following test code does not work with the DB2 driver, although it works fine
with the SQLite3 driver:
local DBI = require 'DBI'
local dbh = assert(DBI.Connect('DB2', 'test'))
dbh:autocommit(false)
DBI.Do(dbh, 'DROP TABLE test')
DBI.Do(dbh, 'CREATE TABLE test (id integer not null primary key, value
varchar(255) not null)')
DBI.Do(dbh, "INSERT INTO test values (1, 'test1')")
DBI.Do(dbh, "INSERT INTO test values (3, 'test3')")
DBI.Do(dbh, "COMMIT")
local sth, err = assert(dbh:prepare('SELECT value FROM test WHERE id = ?'))
if sth == nil then
print('Error preparing statement: ', err)
os.exit()
end
local success, err = sth:execute(3)
if not success then
print('Error executing statement: ', err)
os.exit()
end
row = sth:fetch()
if row ~= nil then
print('3 found: ', row[1])
end
success, err = sth:execute(2)
if not success then
print('Error executing statement: ', err)
os.exit()
end
row = sth:fetch()
if row ~= nil then
print('2 found: ', row[1])
end
success, err = sth:execute(1)
if not success then
print('Error executing statement: ', err)
os.exit()
end
row = sth:fetch()
if row ~= nil then
print('1 found: ', row[1])
end
sth:close()
dbh:close()
print('Done')
The second and subsequent sth:execute calls fail due to an invalid cursor state
as the cursor is still open. I also noticed that the code is quite inefficient
because it allocates memory for the resultset after every execute rather than
when the statement is prepared.
The attached patch keeps track of whether the cursor is still open and closes
it when the statement is re-executed, if required. It also moves the code to
initialise the resultset into the statement_create function to avoid repeatedly
allocating the memory every time the statement is executed.
Any comments welcome.
Original issue reported on code.google.com by [email protected]
on 14 Jun 2015 at 5:26
Attachments:
Hi Neil, this is a feature request. It would be nice to have access to column
names after a select.
LuaSQL provides a colnames function IIRC. This is handy for dealing with
metadata.
Not related, but in the MySQL statement.c, there is this code:
if (!statement->metadata) {
luaL_error(L, DBI_ERR_FETCH_NO_EXECUTE);
return 0;
}
if (!statement->metadata) {
lua_pushnil(L);
return 1;
}
I am not sure the second test is needed.
Original issue reported on code.google.com by [email protected]
on 7 Mar 2009 at 8:15
What steps will reproduce the problem?
1. Just connect to a postgresql server with luadbi
2. PostgreSQL generates a warning "there is already a transaction in progress"
What is the expected output? What do you see instead?
I would see nothing if there is no such issue.
Please provide any additional information below.
I made a patch and commited on a new branch named 'postgres-fix'.
The new branch is in a cloned repository found on
http://code.google.com/p/luadbi/source/clones
Original issue reported on code.google.com by [email protected]
on 17 Oct 2012 at 1:36
Selecting date datatypes using the MySQL driver causes a segfault.
Original issue reported on code.google.com by [email protected]
on 17 Sep 2009 at 11:30
Please consider making a binary package for Windows available through
"luarocks".
Original issue reported on code.google.com by [email protected]
on 22 Oct 2010 at 4:21
# make mysql
gcc -c -o build/dbd_common.o -g -pedantic -Wall -O2 -shared -fpic -I
/usr/include/lua5.1 -I /usr/include/mysql -I /usr/include/postgresql/ -I
/opt/ibm/db2exc/V9.5/include/ -I
/usr/lib/oracle/xe/app/oracle/product/10.2.0/client/rdbms/public/ -I .
gcc: No input files specified
*** [build/dbd_common.o] Error code 1
make script is broken? It comes from archive: luadbi.0.5.tar.gz.
Platform: FreeBSD.
Original issue reported on code.google.com by [email protected]
on 1 Aug 2013 at 10:47
I occured a problem, when I tried to select a dataset from joined tables.
MySQL on CLI brings the right output:
mysql> SELECT
-> c.pos_x,
-> c.pos_y,
-> n.position_x,
-> n.position_y,
-> n.npcs_id
-> FROM npc_instances AS n
-> JOIN chunks AS c ON (c.pk_chunk_id = n.chunk_id);
+-------+-------+------------+------------+---------+
| pos_x | pos_y | position_x | position_y | npcs_id |
+-------+-------+------------+------------+---------+
| 1 | 1 | 120 | 645 | 2 |
| 1 | 1 | 600 | 150 | 3 |
| 1 | 1 | 600 | 270 | 1 |
+-------+-------+------------+------------+---------+
3 rows in set (0.00 sec)
When I select the same Statement via luadbi, the pos_x and pos_y values are
empty:
File: dbitest.lua
require('DBI')
local dbh = assert(DBI.Connect('MySQL', 'obg', 'root', 'NeverGonnaGiveYouUp',
'127.0.0.1', '3306'));
dbh:autocommit(true)
local select = assert(dbh:prepare([[
SELECT
c.pos_x,
c.pos_y,
n.position_x,
n.position_y,
n.npcs_id
FROM npc_instances AS n
JOIN chunks AS c ON (c.pk_chunk_id = n.chunk_id)
]])
);
select:execute();
for row in select:rows() do
print(table.concat(row, " | "));
end
Execution:
$ lua dbitest.lua
| | 120 | 645 | 2
| | 600 | 150 | 3
| | 600 | 270 | 1
I am Using:
Ubuntu 12.04.2 LTS (Precise)
lua-dbi-common Version: 0.5+svn78-2~precise1
lua-dbi-mysql Version: 0.5+svn78-2~precise1
mysql Ver 14.14 Distrib 5.5.31, for debian-linux-gnu (x86_64) using readline
6.2
Is there a bug in DBI or in the driver?
Do you need further information?
Original issue reported on code.google.com by [email protected]
on 8 May 2013 at 5:05
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.