odbc-api icon indicating copy to clipboard operation
odbc-api copied to clipboard

Does odbc-api how to get column comments(Description)

Open baoyachi opened this issue 2 years ago • 5 comments

E.g: how to get config table Description

                                                                      Table "public.basic_config"
   Column    |           Type           | Collation | Nullable |                 Default                  | Storage  | Compression | Stats target |     Description
-------------+--------------------------+-----------+----------+------------------------------------------+----------+-------------+--------------+---------------------
 id          | integer                  |           | not null | nextval('basic_config_id_seq'::regclass) | plain    |             |              | The basic_config id
 center_name | character varying        |           | not null |                                          | extended |             |              |
 enable      | boolean                  |           | not null | false                                    | plain    |             |              |
 create_time | timestamp with time zone |           | not null | now()                                    | plain    |             |              |
Indexes:
    "basic_config_pkey" PRIMARY KEY, btree (id)
Access method: heap

baoyachi avatar Sep 02 '22 08:09 baoyachi

Several ways to do it. You may want to look at the implementation of the columns subcommand of odbcsv. https://github.com/pacman82/odbc-api/blob/18eeb4804d4da934056f0dcc1e6e258e91e7c7ed/odbcsv/src/main.rs#L521

Metadata connected to cursors can also achieve the same thing. https://docs.rs/odbc-api/0.48.0/odbc_api/trait.ResultSetMetadata.html

pacman82 avatar Sep 02 '22 11:09 pacman82

Several ways to do it. You may want to look at the implementation of the columns subcommand of odbcsv.

https://github.com/pacman82/odbc-api/blob/18eeb4804d4da934056f0dcc1e6e258e91e7c7ed/odbcsv/src/main.rs#L521

Metadata connected to cursors can also achieve the same thing. https://docs.rs/odbc-api/0.48.0/odbc_api/trait.ResultSetMetadata.html

Hi @pacman82 : Based on the information you provided, I haven't found a way to get the description.

Actually, I want this value from the table above: The basic_config id

baoyachi avatar Sep 09 '22 16:09 baoyachi

It's not an ODBC feature (at least that I know of). Have you considered just querying that table?

pacman82 avatar Sep 09 '22 16:09 pacman82

Have you considered just querying that table?

I am currently querying the table column name in this way: https://github.com/baoyachi/odbc-api-helper/blob/main/src/executor/database.rs#L143-L165

baoyachi avatar Sep 09 '22 16:09 baoyachi

What I meant is: Have you tried querying that config table you talk about via SELECT. The meta information you search does not seem to be part of the ODBC standard.

pacman82 avatar Sep 09 '22 17:09 pacman82

Not in scope of odbc-api. Closing issue.

pacman82 avatar Sep 16 '22 07:09 pacman82