LUA and MS SQL Server
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

LUA and MS SQL Server

Started by xfernal, 07 January, 2004, 20:49:43

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

xfernal

I recently moved over from the darkside as I have been running a Neo-Modus hub for over 2 years now. I had written several scripts for N-M hub that queried a MS SQL Server database. One of the scripts I wrote queried a MS SQL Server database for any users that registered for an account on the website and added them to the registered users list in the hub. My problem is that while I know how to script a database connection and run a query  in VB, I have no idea how to in LUA. Can anyone point me in the right direction to get started on this task? I would gladly share the code if someone can provide a basic example.

plop

well a simple way 2 do that without sql is 2 make the website write a txt file.
next you let the bot in your hub search for that file and if it excists it grabs the username/pw and adds it as user.
finaly the bot deletes the file.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

xfernal

#2
The only issue with that is if you script it to check for a file and add the user then delete the file, then if the hub crashed without saving the registered users list, then all the users that were added would be lost. I originally had set up Neo-Modus hub doing that exact thing with a script I wrote. It became a real problem when N-M hub did crash...which was often. I then changed the script to query the database every 3 minutes to get a list of users and compare to the hub registered users. That seemed to be quicker. I guess at worst I will have the website generate a file for each new activation in one directory. Have a LUA script query it and add the users and delete the file AND have the website to generate a textfile of all the users and have it to loop through the hub registered users and compare AT hub startup time. Does LUA have the equivalent of the Dictionary Object in VB?

Even though that would fix the syncing problem, I still lose the ability to query my database for information. I run a lossless audio hub and the website provides information about bootlegs. I had a script that would let you trigger a command to search the database. You could search by band or date. As well as query about website statistics. I would really like to know how to query a database with LUA.

plop

well ptokax isn't nmdc hub, crashing ptokax is a lot harder 2 do (and i really mean a lot harder, i can't even close down windows when td is running), and adding a user sure isn't gone cause a crash.
searching a website is posible just like sql but there are some but's 2 it.
2 search things like that you need 2 open a socket, doing this freezes the bot/hub while it's open.
so if there is a way 2 do it without a socket is always a better idea.
i never looked up how 2 query a sql database from the scripts as it was gone be added 2 ptokax (no idea if it still whill be, if so i'm gone learn it as fast as posible).
currently most of us make our own databases in lua, as that can be/is faster then sql (if good written).

for more info abour searching a website i hope chilla/pur respond here as they know that better then me.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

c h i l l a

I don't know about sql, but reading out a txt file sounds good to me :).
and if ptokax should crash on adding nick then the function wouldn't be finshed anyways and the file wouldn't get deleted.

about the html, thing.. you need sockets, unless, your page is on a local path.

if not then connect to the server.

send your get command

recieve the lines.

search the lines for what you need.


here is a script that connects to imdb and freedb over http through a socket.

http://fdw.ath.cx/p.scripts/imdb.freedb.http-V.1.2.rar

NotRabidWombat

xfernal is right. Databases offer more speed and stability than simply writing to txt files, it's why they exist. There is a solution in Lua 5.0 in modules. Unfortunetly, PtokaX still uses Lua 4.x which does not support the neccessary modules. It would be nice to see in upgrade of Lua in the next release of PtokaX, if there ever is one ;-)

plop, the shutdown issue is a bug, not a feature. The conflicts arises with the "Are you sure you want to close" dialog box.

Maybe the next step of this forum should be to create a bug and request tracker?

-NotRabidWombat


I like childish behavior. Maybe this post will be deleted next.

Optimus

Me smell Brains. *lol*

Nice idea

c h i l l a

#7
are there sockets already for Lua 5.0 ??

other question..  is a database faster than a Lua table hashing, just curious,  cause I think I've seen a webserver in Lua or something similiar, so maybe one can write the whole page and its database in Lua.

plop

QuoteOriginally posted by NotRabidWombat
xfernal is right. Databases offer more speed and stability than simply writing to txt files, it's why they exist. There is a solution in Lua 5.0 in modules. Unfortunetly, PtokaX still uses Lua 4.x which does not support the neccessary modules. It would be nice to see in upgrade of Lua in the next release of PtokaX, if there ever is one ;-)

plop, the shutdown issue is a bug, not a feature. The conflicts arises with the "Are you sure you want to close" dialog box.

Maybe the next step of this forum should be to create a bug and request tracker?

-NotRabidWombat
stabilety yes, if windows would crash i can loose part or even the whole database, but speed i'm not 2 sure.
i can search thru 10.000 users for an ip in 0 secs, for sql you 1st have 2 connect (or can you keep it open all the time?).
i know sql can do it fast (used 2 be using a webfilter with a sql database and that was fast as lightning) and on complex searches certainly out preform lua, for example partial ip's (would take about 0.5 secs on lua itself).
if ptokax would switch 2 lua 5.0 i would switch 2 sql without a doubt.
keep faith 1 day there whil be a new ptokax.

i know that it's a bug but sure a stable 1. lol
on my previous windows install i changed some settings so even on that dialog windows "should" shutdown, but it didn't (that dialog still doesn't show here, must be me, i can crash anything as i love 2 push buttons).

that bug/requests tracker sure is a good idea, could solve some over and over asked questions (could, i don't wanne be mean but for some ppl the search button is really hard 2 find).

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

xfernal

Quotefor sql you 1st have 2 connect (or can you keep it open all the time?).
-plop

You can do either. I always open my connections at the beginning of a function where I need them and close my connections at the end of the function. That way the connection is open only as long as I need it rather than tying up extra memory while idle. But some people just leave a connection open all the time.

Well since it doesn't look like I can connect to MS SQL Server, I will have to rethink how I am going to do this.

Maybe I need to create a small VB application that will form the sql statements based on parameters sent via a LUA script and process them and give the results back to the LUA script. Just an idea, the only issue I see is that some of the SQL queries that search all the records in the database can be slow (some take up to 2 seconds as we have over 16,000 entries for bootlegs) if all columns need to be searched. I will have to write my own timeout script for LUA I suppose.

Anyone got a better idea?

c h i l l a

#10
2 seconds, is this a search for album and artist and for a part of the artist or only a search for, the exact artist and exact album ? And how fast is your processor? and how fast your Memory?

xfernal

#11
The queries that can take 2 seconds are ones that are searching through all the songs for a show (setlist) and that is only when the database server is under heavy  traffic. Queries that involve artist name or dates are less than 1 second.

Ex.
SELECT * FROM Media Where Setlist LIKE '%whatever%'

The webserver is a Dual P3 700 with 1GB RAM. Thats also what the hub is running on. The database server is a Dual 500 with 768MB all 10,000 RPM SCSII harddrives, RAID5. I am running Win2003 Server on the web server and Win2000 Adv. Server on the database server with MS SQL Server 2000.

SMF spam blocked by CleanTalk