[Tinymux] @query/sql

David Cheatham david at mush.cx
Fri Nov 25 10:41:12 EST 2005


Stephen Dennis wrote:
> http://www.tinymux.org/wiki/index.php/SQL
> 
> We covered this area several years ago. There was some good feedback
> from that. Unfortunately, I cannot find that feedback anymore.
> 
> Proposed syntax 1 matches
> http://docs.btmux.com/index.php/Command:@query and superficially
> matches @wait.
> 
> I saw superficially because @wait <object>/<attribute>=<command> does
> actually wait on the <object>/<attribute> to be @notified. What is
> being @wait'ed on is the part that comes before the equal side.
> 
> Proposed syntax 2 matches @program
> 
> Like the @wait form above, @program is wait'ing on the <player> which
> is given before the equal side.
> 
> Matching this form would require something like: @query/sql
> <dbname>/<query>=<dbref>/<attribute>. However, finding the equal side
> after the <query> would be troublesome.

That is what I basically came up with, except I did

@asql <dbref>/attribute>=<query>

Which I think makes a lot more sense, because then you don't have to try 
to parse <query>. (asql stands for async sql, but @query is fine.)

Note you don't need dbname. You can select which db you're using inside 
the query, aka, 'SELECT * FROM dbname.table' Although using multiple 
databases in the same game is just silly. (1)

And I returned it as an @trigger, handing back not only the result, but 
the query and the rowcount. And any r-registers that were set, which 
lets you answer questions like 'Who asked for this information?'. ;)

Note this code is not actually in the public anywhere, or even a 
workable form, it's just what I came up with.

An unanswered question: How do you specify row and column delimiters? 
Possibly @query <dbref>/attribute>=<row>,<col>,<query>

That would work, because sql queries can't possibly be one character long.

1) If you actually want to support that, I'd make a @SQLDATABASE 
attribute to specify the default database for that object, which is 
missing means use the default one. (But remember, if you ever switch the 
default DB, you have to switch it back, or everyone else's query will 
break. Which just sucks up needless time. It's probably better to just 
have one default, and make anyone explicitly list others in the query.)


More information about the Tinymux mailing list