Issue Details (XML | Word | Printable)

Key: PYFB-44
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Pavel Cisar
Reporter: Dominik Psenner
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Firebird driver for Python

Inserting a datetime.date into a TIMESTAMP column does not work

Created: 11/Nov/14 10:17 AM   Updated: 13/Nov/14 01:33 PM
Component/s: None
Affects Version/s: 1.4.1
Fix Version/s: 1.4.2


 Description  « Hide
Looks like the conversion does not handle the datetime.date datatype properly.

Traceback (most recent call last):in __read
  File "fdb\\fbcore.pyo", line 3338, in execute
  File "fdb\\fbcore.pyo", line 3006, in _execute
  File "fdb\\fbcore.pyo", line 2812, in __Tuple2XSQLDA
  File "fdb\\fbcore.pyo", line 2270, in _convert_timestamp
AttributeError: 'datetime.date' object has no attribute 'date'

 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Dominik Psenner added a comment - 11/Nov/14 10:36 AM
There is an obvious workaround of combining the datetime.date object into a datetime.datetime datatype when one knows he is going to write a datetime.date object into a TIMESTAMP just like this:

from datetime import date
from datetime import datetime
dateToInsert = datetime.date.today()
fixedDateToInsert = datetime.combine(dateToInsert, datetime.min.time())

But it would look much more pythonic if this was implicitly handled by the conversion function.