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

Expose sql_type information about columns in resultset #167

Open
jstastny-cz opened this issue Dec 17, 2016 · 4 comments
Open

Expose sql_type information about columns in resultset #167

jstastny-cz opened this issue Dec 17, 2016 · 4 comments
Labels

Comments

@jstastny-cz
Copy link

I am looking for an extension of metadata returned through Cursor.
For every column in a result set I'd like to be able to get sql_type code of that column.
Together with getTypeInfo method of cursor, user can get further information about the datatype.

jstastny-cz pushed a commit to jstastny-cz/pyodbc that referenced this issue Dec 17, 2016
@findepi
Copy link

findepi commented Dec 15, 2017

Same here. https://github.com/mkleehammer/pyodbc/wiki/Cursor#description docs suggests that it returns just that:

  1. type code

but instead it returns Python type that values will be mapped to (e.g. str, int, datetime.time etc.)

@mkleehammer is there a way to get original (ODBC-level) type information?

@jstastny-cz
Copy link
Author

@findepi
Hello,
there is a way. You can get it from the odbc driver. Actually, I've implemented the extension in my fork of this project, if you're interested.

@findepi
Copy link

findepi commented Dec 17, 2017

@jstastny-cz , is it Cursor#colinfos (https://github.com/jstastny-cz/pyodbc/blob/c278e74e44341a4333dbd2b471758b651abc7558/src/cursor.h#L112)?
Looks like that would be it! Are you planning on making a PR with this enhancement?

@jstastny-cz
Copy link
Author

@findepi
Not that one.

I exposed the information in an additional field 'coldescription':
https://github.com/jstastny-cz/pyodbc/blob/2f703c07a98c70ac369e77603abd98e681204421/src/cursor.h#L117

and the PR is already in place (it never got into the project, as it is not project's priority I am afraid):
#168

celestialorb added a commit to ccpgames/pyodbc that referenced this issue Aug 29, 2019
Expose sql_type for columns in resultset mkleehammer#167
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants