[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: RE: SQL syntax in Lua?
- From: "Dowling, Brendan" <bdowling@...>
- Date: Wed, 8 Mar 2006 00:49:28 -0700
See the Lua SQLite project for an excellent example of a way to do this.
SQLite is an embedded SQL database that is a perfect match for an embedded scripting language like Lua. It basically lets you do cool things like:
db = sqlite.open("somefile")
for row in db:rows("SELECT * FROM users WHERE id>0") do
db:exec("some sql statement")
et cetera. If you're comfortable with Lua, you'll like SQLite.
From: email@example.com on behalf of PA
Sent: Tue 3/7/2006 11:29 PM
To: Lua list
Subject: SQL syntax in Lua?
I would like to, hmmm, use some SQL like syntax in Lua and I was
wondering if anyone had any thoughts on such endeavor?
My current thinking is to chain function calls which mimic SQL
constructs. Something along these lines:
DB:Select( 'name' ):
From( aSource ):
Where( 'name', 'like', '%joe%' ):
Where( 'city', '=', 'NYC' ):
Order( 'name' )()
Or perhaps wrap the above in a function call which would execute in a
custom environment (providing additional substitution magic along the
local aStatement = function()
Select( name )
From( aSource )
Where( name, like, '%joe%' )
Where( city, eq, 'NYC' )
Order( name )
DB:run( aStatement )
Any thoughts on such constructs?
Thanks for any insights!
PA, Onnay Equitursay