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

Couldn't parse date string 'datetime.date(2022, 3, 25)' with SQLAlchemy #22

Open
jimmymaise opened this issue Mar 8, 2022 · 0 comments

Comments

@jimmymaise
Copy link

jimmymaise commented Mar 8, 2022

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

image

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')

`

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

No branches or pull requests

1 participant