Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API for accessing column names and types #15

Open
dvic opened this issue Jan 21, 2025 · 4 comments
Open

API for accessing column names and types #15

dvic opened this issue Jan 21, 2025 · 4 comments

Comments

@dvic
Copy link
Contributor

dvic commented Jan 21, 2025

In Esqlite we can do

    %% All columns
    {ok, Stmt} = esqlite3:prepare(Db, "select * from test_table"),
    ?assertEqual([<<"varchar(10)">>, <<"INT">>], esqlite3:column_decltypes(Stmt)),

and

{ok, Stmt} = esqlite3:prepare(C, "select 1 as one"),
    ?assertEqual([<<"one">>], esqlite3:column_names(Stmt)),

    {ok, Stmt1} = esqlite3:prepare(C, <<"select 1 as 😀"/utf8>>),
    ?assertEqual([<<"😀"/utf8>>], esqlite3:column_names(Stmt1)),
    
    {ok, Stmt2} = esqlite3:prepare(C, <<"select 1">>),
    ?assertEqual([<<"1">>], esqlite3:column_names(Stmt2)),

(copied from one of the tests)

Can we somehow support this as well? (without necessarily exposing prepared statements and such)?

My use case: I'm trying to write a ascii table snapshot of parts of my database and I want to be able to do this dynamically without knowing the columns upfront.

@dvic dvic changed the title Expose Expose column names and types Jan 21, 2025
@dvic dvic changed the title Expose column names and types API for accessing column names and types Jan 21, 2025
@lpil
Copy link
Owner

lpil commented Jan 21, 2025

Sounds good to have!

@dvic
Copy link
Contributor Author

dvic commented Jan 21, 2025

Was there a reason you left out prepared statements from the API? Is that the preferred approach for this feature or did you have something else in mind? Like query_with_metadata?

@lpil
Copy link
Owner

lpil commented Jan 21, 2025

No reason, and I don't have any ideas.

@dvic
Copy link
Contributor Author

dvic commented Jan 21, 2025

No reason, and I don't have any ideas.

Cool, then I'll see if we can have a prepared statement api that covers both esqlite and the deno library!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants