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

Add Cursor.definition property #131

Closed
rogerbinns opened this issue Dec 29, 2013 · 5 comments
Closed

Add Cursor.definition property #131

rogerbinns opened this issue Dec 29, 2013 · 5 comments

Comments

@rogerbinns
Copy link
Owner

From piranna on May 11, 2012 12:44:25

On DB-API 2.0, the Cursor instances has a definition property that has the same purpose and return similar data that the getdefinition() method, and also the most used data of the returned tuples (the name of the columns) is in both at the offset 0, but since you can't subclass the APSW Cursor class you can't be able to add the property and develop portable code at this point. The fact is that is easy to get over this with some code like:

try:
    description = cursor.description
except AttributeError:  # APSW
    description = cursor.getdescription()

but it's ugly since you have to had specialized code for something fairly trivial. Since that, i propose to add a definition property according to the DB-API 2.0. This states that it have to return a tuple with the next fields:

name, 
type_code, 
display_size,
internal_size, 
precision, 
scale, 
null_ok

Since the first two are the same that the getattribute() method it should be fairly trivial, while for the other five since don't have sense on SQLite it could be possible to do the same that PySqlite does, that it's just return None on the fields.

Original issue: http://code.google.com/p/apsw/issues/detail?id=131

@rogerbinns
Copy link
Owner Author

From rogerbinns on May 11, 2012 13:15:44

If you are happy with the description property returning the same as getdescription with 5 Nones appended them I'm happy to add this.

I usually shy away from DB API stuff like this since SQLite really doesn't work that way and providing the methods can easily mislead that it does.

Status: Accepted
Labels: -Type-Defect Type-Enhancement

@rogerbinns
Copy link
Owner Author

From piranna on May 11, 2012 13:19:17

Yes, it's just what i was asking for :-D In fact i have just made a clone to try to do it and send you a pull request :-)

@rogerbinns
Copy link
Owner Author

From rogerbinns on May 11, 2012 13:26:17

Don't worry about doing it yourself. It isn't much code, and the test code will be longer anyway.

This will be in 3.7.12 which is awaiting that SQLite version. It should be happening very soon.

@rogerbinns
Copy link
Owner Author

From piranna on May 11, 2012 13:28:00

Ok, thanks :-)

@rogerbinns
Copy link
Owner Author

From rogerbinns on May 13, 2012 18:09:44

This issue was closed by revision d1b234e5ceb9 .

Status: Fixed

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

No branches or pull requests

1 participant