[Tinymux] @query/sql
Stephen Dennis
brazilofmux at gmail.com
Fri Nov 25 13:28:13 EST 2005
Perhaps <dbname> is something of a misnomer. Imagine using either a
mix of MySql, postgresql, and mSql. Or, imagine using two MySql boxes.
Or, potentially, imagine using two different user contexts to the same
MySql server.
The <dbname> then is not used to specify a particular table or
database, but it represents a separate 'connection' or 'session' to a
SQL server.
With respect to delimiters, remember that I'm planning to return the
entire results set and then use separate functions to navigate that
results set. The delimiter will be given to those other functions.
Maybe a hypothetical example will help make it clearer.
> &row.tr SQL=@pemit %#=rsfields(1,2,|)
> &results.tr SQL=@ifelse not(rsend())={@trig row.tr;rsnextrow();@trig results.tr}
> @query/sql SQL/results.tr=mysql/SELECT * FROM mytable
John|Doe
Bilbo|Baggins
Luke|Skywalker
I haven't settled on the specific functions used to navigate the
results set, but the point is that the results set could be 1MB large,
but as long as no individual field is larger than 8KB, we can still
use softcode to navigate it.
The results set and position context in results.tr is given to row.tr
at the @trig row.tr. This example has some drawbacks in that it will
generate as many queued commands as there are rows in the results set.
Brazil
On 11/25/05, David Cheatham <david at mush.cx> wrote:
> 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.)
> _______________________________________________
> Tinymux mailing list
> Tinymux at tinymux.org
> http://www.tinymux.org/mailman/listinfo/tinymux
>
More information about the Tinymux
mailing list