Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I was experimenting with APSW and I noticed that when a query doesn't return any row, it becomes difficult to get column names from the cursor, is there any recommended way to do this ?


If you ask via the contacts such as Github discussions or email then I can help find a perfect solution for your needs - https://rogerbinns.github.io/apsw/about.html#mailing-lists-c...

As you found out this happens because the cursor is immediately exhausted as there are no rows, and then is cleaned up and so column data names are not available.

You can use apsw.ext.query_info to get details about a query without running it - see https://rogerbinns.github.io/apsw/ext.html#apsw.ext.query_in... which includes an example.

Behind the scenes you can use an execution tracer to extract the information. That is what query_info does. although it aborts execution after recording it.

(I am the APSW maintainer)


Thanks for the detailed explanation, I will try with apsw.ext.query_info. In my case I was building column-keyed dicts from results but as the result was an empty set, there was nothing to key on. Appreciate the pointer to the execution tracer too.




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: