[q2x] OT: Lua questions

Nick Trout nick at rockstarvancouver.com
Wed Jan 21 20:55:20 EST 2004


> I'm using Lua (I think) in an unrelated project, and was wondering if
> y'all could provide some advice.
> 
> I have a database of users managed through SQL (note: I refuse to use
> LuaSQL since it's very poorly documented).  I have a C layer, the Lua
> layer, and then a set of MySQL databases.
> 
> I'm trying to figure out the right way to handle basic stuff like
> querying the MySQL db from Lua, etc.
> 
> Right now my inclination is that specific queries in Lua are handled
> by proxy through the C layer.  Oh, and I have a telnetd written in C.
> 
> So, er, the architecture is kind of like this:
> 
> C layer/network driver -> (received text) -> Lua
> Lua -> (queries) -> C layer -> (queries) -> SQL db
> 
> Using a trivial example, someone telnets to my app and I have to
> verify their authenticity (yes, telnet is all cleartext, not a problem
> for now).  I accept() the connection for now, and then future data
> from that is automatically forwarded to the Lua subsystem, which in
> turn is responsible for prompts, etc. to the user and asking for their
> username, querying the MySQL user database for authenticity, etc.
> 
> Any suggestions for the "right" way to handle this?

I suppose that's highly subjective, but personally I'd think about
writing the whole thing in Python. No Lua, No C, and optional MySQL. The
MySQL bit possibly be serialised with Python pickling depending on how
much data you have and the architecture you require. Lua is great for
embedding and extending but you could write you whole system in Python
and avoid the glue/architecture problem. Python is a great language for
prototyping and "freestyle" programming is you're unsure where the
project is going. You'll save a lot of time on refactoring later and
unit testing is a breeze. There are a lot of server side apps written in
Python (e.g. MoinMoin, Zope) which have pretty high performance. Zope
runs off a Python database system called ZODB which you could possibly
use. I wouldn't try using Zope (just ZODB) though as it's really
complicated.

Nick






More information about the q2x mailing list