There's also this:

(query-rows db
            "
                SELECT column_name
               FROM information_schema.columns
               WHERE table_schema = 'your_schema'
                         AND table_name   = 'your_table'
")

On Wed, Dec 28, 2016 at 12:46 PM, Philip McGrath
<phi...@philipmcgrath.com> wrote:
> Something like this would be really good. I also, relatively recently,
> discovered the "name" fields when I happened to look at a rows-result
> directly, and being able to work with columns by name rather than by
> position is much better. I guess I should have realized there was some way
> of doing this, because rows->dict and the library functions that accept a
> #:group argument can use column names. More documentation would definitely
> be helpful: for example, I've noticed that I need to convert all of my
> strings for #:group arguments to lower case, at least with postgresql.
>
> On Wed, Dec 28, 2016 at 10:21 AM 'John Clements' via Racket Users
> <racket-users@googlegroups.com> wrote:
>>
>> For the last few years, I’ve believed that there was no way to get the
>> column names of tables using the db interface. Today I discovered that—using
>> both postgresql and sqlite3, at least—I can extract these from the “name”
>> fields of the “headers” field of the row-response to a “SELECT * FROM
>> table_name LIMIT 0;”. The documentation suggests that these header fields
>> are fragile and undocumented… but it would be nice to have known that it was
>> there. Would it make sense to add a library function that returns column
>> name information if it’s available, or at least add some sample code to the
>> documentation?
>>
>> John
>>
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to racket-users+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to