[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: Names for database access functions
- From: Thijs Schreijer <thijs@...>
- Date: Thu, 18 Jun 2015 07:46:16 +0000
> -----Original Message-----
> From: lua-l-bounces@lists.lua.org [mailto:lua-l-bounces@lists.lua.org] On
> Behalf Of Brigham Toskin
> Sent: donderdag 18 juni 2015 1:25
> To: Lua mailing list
> Subject: Re: Names for database access functions
>
> I might call them rows (hashed tables), and rowvals or values or something
> similar (multi returns). I probably wouldn't ever use the array indexed
> style, unless it was actually meaningful to the data. And in that case, it
> would probably be a list packed into single column, so it would look more
> like:
>
> for t in db:rows("...") do print(table.unpack(t.phonenumbers)) end
>
> But that feels pretty janky anyway, and I'd probably slap my DBA for doing
> something like that.
>
> On Wed, Jun 17, 2015 at 2:43 PM, Geoff Leyland <geoff_leyland@fastmail.fm>
> wrote:
> Hi,
>
> When you access a database, you might want to receive results from a query
> as a multiple return value, an array, or as a table with column names. For
> example:
>
> for first, last in db:rows“SELECT first, last FROM people” do
> print(first, last) end
>
> or
>
> for array in db:rows“SELECT first, last FROM people” do print(array[1],
> array[2]) end
>
> or
>
> for table in db:rows“SELECT first, last FROM people” do
> print(table.first, table.last) end
>
> I find that I use the first and last example, but not so much the middle,
> array, form (but that’s just me).
>
> What should each of these functions be called? The database binding I use
> frequently that actually offers a “rows" iterator [1] calls them:
> - “rows” for the array case that I don’t really use
> - “nrows” for the table case (I guess that stands for “named rows”?)
> - “urows” for the multiple return case (I’m not sure what the u stands for)
>
> Can anyone suggest a better naming convention? I ask because I’ve written
> myself a yet-another database-adapter on top of the other database adapters
> [2] to make them look the same, and (to my eyes at least) slightly more
> pleasant.
>
> Cheers,
> Geoff
>
> [1] lsqlite3[3]. luapqsql[4] and luasql[5] offer primitives that allow you
> to build your own iterators
> [2] https://github.com/geoffleyland/lua-patengi
> [3] https://github.com/LuaDist/lsqlite3
> [4] https://github.com/mbalmer/luapgsql
> [5] https://keplerproject.github.io/luasql/doc/us/manual.html#introduction
>
>
>
>
>
> --
> Brigham Toskin
@Brigham; in case nobody on this list has commented on your postings before, let me warn you. In general top-posting is considered a bad habit around here. I have seen others vigorously attack posters who did that, really nasty to witness as a by stander, bits and pieces all over the place.... Now I, for one, would never do such a thing of course, me being such a nice guy overall. As you also seem to be a pretty decent guy, I felt obliged to warn you...
:)
Thijs