Couldn't parse date string 'datetime.date(2022, 3, 25)' with SQLAlchemy
jimmymaise opened this issue · 0 comments
Without SQL alchemy, everything is OK. However, as I have a demand to move to real database in the future, i decided to apply SQL alchemy.
I'm using SQL alchemy and follow the instruction in here #13
However, I got the error when running table.select()
File "/Users/duyetmai/.local/share/virtualenvs/slack_bot-_UTJr7MR/lib/python3.7/site-packages/sqlalchemy/engine/result.py", line 383, in iterrows row = make_row(row) if make_row else row ValueError: Couldn't parse date string 'datetime.date(2022, 3, 25)' - value is not a string.
Here is the sheet data
After that, instead of using autoload=True
, I tried to apply the schema
`
Column('id', UUID(as_uuid=True), primary_key=True, default=uuid.uuid4),
Column('username', String()),
Column('start_date', Date()),
Column('end_date', Date()),
Column('leave_type', String()),
Column('reason', String()),
Column('created_time', DateTime()),
Column('status', String()),
Column('approver', String()),
`
However, still have the same error, so I changed all Date/DateTime Field to String and it works OK. Here is the print result after changing to string
`
Column('start_date', String()),
Column('end_date', String()),
Column('created_time', String()),
`
(UUID('a91fb8ef-a456-4ab5-87ec-51505c08d831'), 'Xzz', datetime.date(2022, 3, 25), datetime.date(2022, 3, 26), 'PTO', 'PTO', datetime.datetime(2022, 3, 5, 6, 19, 42, tzinfo=datetime.timezone.utc), 'Wait for Approval', 'ABC')
(UUID('130223f1-b501-4079-95f4-8de003659a0e'), 'zzzz', datetime.date(2022, 3, 3), datetime.date(2022, 3, 18), 'PTO', 'PTO', datetime.datetime(2022, 3, 5, 6, 57, 45, tzinfo=datetime.timezone.utc), 'Approved', 'ABC')
`