sqlight
sqlight copied to clipboard
API for accessing column names and types
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.
Sounds good to have!
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?
No reason, and I don't have any ideas.
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!