PtokaX forum

Development Section => Extensions for PtokaX Lua => Topic started by: PPK on 07 December, 2007, 20:21:51

Title: Lua-SQLite for 0.3.6.0d and newer
Post by: PPK on 07 December, 2007, 20:21:51
Updated to use with newer PtokaX versions and updated SQLite from 3.2.7 to 3.5.3 :)

Binary: PXLua-SQLite-0.4.1-SQLite-3.5.3.7z (http://www.ptokax.org/files/Libs-0.3.6.0d/PXLua-SQLite-0.4.1-SQLite-3.5.3.7z)

Source: PXLua-SQLite-0.4.1-SQLite-3.5.3-src.7z (http://www.ptokax.org/files/Libs-0.3.6.0d/PXLua-SQLite-0.4.1-SQLite-3.5.3-src.7z)
Title: Re: Lua-SQLite for 0.3.6.0d and newer
Post by: Rincewind on 07 December, 2007, 23:47:24
Think you forgot the links PPK  :P
Title: Re: Lua-SQLite for 0.3.6.0d and newer
Post by: PPK on 26 January, 2008, 13:28:47
PXLua-SQLite-0.4.1-SQLite-3.5.3 compatible with PtokaX 0.4.0.0RC6
http://www.PtokaX.org/files/Libs-0.4.0.0RC6/PXLua-SQLite-0.4.1-SQLite-3.5.3.7z
Title: Re: Lua-SQLite for 0.3.6.0d and newer
Post by: PPK on 17 March, 2008, 17:55:21
Update http://www.PtokaX.org/files/Libs-0.4.0.0/PXLua-SQLite-0.4.1-SQLite-3.5.6.7z
Title: Re: Lua-SQLite for 0.3.6.0d and newer
Post by: Psycho_Chihuahua on 17 March, 2008, 18:02:24
Quote from: PPK on 17 March, 2008, 17:55:21
Update http://www.PtokaX.org/files/Libs-0.4.0.0/PXLua-SQLite-0.4.1-SQLite-3.5.6.7z

-Mirrored- (http://forum.ptokax.org/index.php?action=tpmod;dl=get60)
Title: Re: Lua-SQLite for 0.3.6.0d and newer
Post by: Setuper on 24 June, 2008, 13:14:49
Quote from: PPK on 17 March, 2008, 17:55:21
Update http://www.PtokaX.org/files/Libs-0.4.0.0/PXLua-SQLite-0.4.1-SQLite-3.5.6.7z
I cann't create more the one table in the base   >:(
Title: Help with it please! :\
Post by: Nickolya on 15 July, 2008, 10:57:23
Quote from: Setuper on 24 June, 2008, 13:14:49
I cann't create more the one table in the base   >:(
Yes, I have this problem too & at all versions of libs & hubs...  :'(
Wanted to use SQLite in my new scripts but can not to do it. Can somebody help with this, please?!
Error after db:prepare in try to create second table: "SQL logic error or missing database". With one table in db it works perfectly.
P.S. Sorry for my bad english.  :D
Title: Re: Lua-SQLite for 0.3.6.0d and newer
Post by: Nickolya on 16 August, 2008, 01:49:20
The question is already actual :) Can somebody make workable library for new PtokaX to work with SQL database? It's too good thing to forget about it! ;)
Title: Re: Lua-SQLite for 0.3.6.0d and newer
Post by: zigzagkms on 09 October, 2008, 08:10:50
I require in working libraries mysql for ptokax 0.4.1.1, would combine ptokax and mysql without connection of additional libraries, functions most ptokax. Really nobody нуждаеться in it except for me? I do not think that this process is too combined in realization while it is necessary for much and would be very useful in a writing of scripts, would make and ptokax was the best is conclusive.. Forgive for my English, work of the translator
Title: Re: Help with it please! :\
Post by: ATAG on 09 October, 2008, 12:13:45
Quote from: Nickolya on 15 July, 2008, 10:57:23
Yes, I have this problem too & at all versions of libs & hubs...  :'(
Wanted to use SQLite in my new scripts but can not to do it. Can somebody help with this, please?!
Error after db:prepare in try to create second table: "SQL logic error or missing database". With one table in db it works perfectly.
P.S. Sorry for my bad english.  :D
I use it with several tables without any problems (on nix)

require "luasql.sqlite3"
env = assert(luasql.sqlite3())
con = assert(env:connect("test.db"))

assert(con:execute("CREATE TABLE test1 (id integer prinary key, data text)"))
assert(con:execute("CREATE TABLE test2 (id integer prinary key, data text)"))
con:close()
env:close()
UDPDbg.Send("[LUA] 2 tables created successfully :)")


Quote[12:12:35] 2 tables created successfully :)

PS: there isn't any problem likewise with mysql
Title: Re: Lua-SQLite for 0.3.6.0d and newer
Post by: Nickolya on 10 October, 2008, 18:25:06
Yes, on nix it works nice, but we can't make scripts for all with using sqlite because a lot of hubs works at windows, and win lib is not usable, I tryed to work with it, so it's probably to create second table and row in db, and query with "WHERE" don't return any row or return all table. Can't U try to rebuild the win lib, pleeze?!?!
Offtop: F**ken Windows...

And second question: why ptokax use not original libs (with Px at begining), as I know, it's aviable to make programm that use standart lua.dll, can't U make hub without this changes, and we will be able to use all lua libs in our scripts, like at *nix?
Title: Re: Lua-SQLite for 0.3.6.0d and newer
Post by: Snooze on 10 October, 2008, 18:34:03
FYI: I've had a few goes at mysql on ptokax.

I had great success on older versions, though after API2 I've been unable to do ex. updates to exsisting tables when dealing with multible tables.
This could be due to lack of skills/understanding, though I must say that I've done more than enough testing, that those should be ruled out.

I strongly suggest that the convert to ptokax had a bad impact on this lib rendering semi-useless.

That said, I 100% back the suggestion that doing userreg listing in a sqlite style is a bad idea.
Mostly due to the superb job done by PPK in optimizing the internal version, but also in that sqlite is far slower than even simple tables, unless you're dealing with HUGE numbers (10.000+).

Greets,
Snooze
Title: Re: Lua-SQLite for 0.3.6.0d and newer
Post by: PPK on 10 October, 2008, 19:26:39
Quote from: Nickolya on 10 October, 2008, 18:25:06
as I know, it's aviable to make programm that use standart lua.dll
Here is no standard lua.dll. Lua is released as source, any available libraries are everything but not standard.
Afaik most popular are lua binaries from luaforge, but they can't be used for PtokaX for many reasons (they changing library names, no binary compatible with 32 bit PtokaX compiler, bad compiler settings for 64 bit version that make it impossible to use with 64 bit PtokaX...).
Another reason why is not possible to use some available lua libs is that pxlua have changed memory management and fixed some bugs (for example crash on division by zero).
Title: Re: Lua-SQLite for 0.3.6.0d and newer
Post by: Nickolya on 10 October, 2008, 20:34:35
Ok, thx for explain. And can't U make a little guide how to compile libs for new api (we can't understand about name mangling, no _ in begin of functions), for VS or borland, for example. With old api version it's all ok. Will be very glad to know this. Thanks!
Title: Re: Lua-SQLite for 0.3.6.0d and newer
Post by: PPK on 10 October, 2008, 21:13:05
PtokaX lua api have nothing to do with libs. _ was on function begin in older versions because they use C calling convention, and calling convention was changed when CrazyGuy reported that pxlua is slow to fastcall calling convention (using cpu registers for passing function parameters and in testing script it take 33 % less cpu time to finish).
You can use source of any of libs compiled by me to see how to compile libs, only thing that you need to change is that calling convention in compiler settings  8)
Title: Re: Lua-SQLite for 0.3.6.0d and newer
Post by: PPK on 01 February, 2009, 22:39:48
Update http://www.PtokaX.org/files/Libs-0.4.0.0/PXLua-SQLite-0.4.1-SQLite-3.6.10.7z
http://www.PtokaX.org/files/Libs-0.4.0.0/PXLua-SQLite-0.4.1-SQLite-3.6.10-src.7z
Title: Re: Lua-SQLite for 0.3.6.0d and newer
Post by: CrazyGuy on 04 February, 2009, 15:03:33
There's a small problem with the lua files in the script folder included in the package.

Search "sqlite3.lua" and "luasql-sqlite3.lua" for
local init, error = package.loadlib("pxsqlite3", "luaopen_pxsqlite3")

And replace this with
local init, error = package.loadlib("pxsqlite3.dll", "luaopen_pxsqlite3")

That should do the trick when having the PxSqLite3.dll in the root folder of PtokaX :)
Otherwise the path must also be specified relative to the PtokaX folder (i.e. "./scripts/libs/pxsqlite3.dll")

Quote from: package.loadlib (libname, funcname)This is a low-level function. It completely bypasses the package and module system. Unlike require, it does not perform any path searching and does not automatically adds extensions. libname must be the complete file name of the C library, including if necessary a path and extension.