Redash version 4.0.0

datetime module has been imported

[Question] strptime cannot be used

When I wrote the following code in Python, the following error was output.

from datetime import datetime
dt = datetime.strptime (‘2020-01-01’, ‘% Y-% m-% d’)
Error running query:<type ‘exceptions.Exception’>‘_strptime’ is not configured as a supported import module
strftime can be used

The following code did not cause an error and printed the value.

now = datetime.now (). strftime ("% Y-% m-% d")

As you can see, the datetime module seems to be able to be imported into Redash, but why can't I just use strptime?

I look forward to working with you.

  • Answer # 1

    It may be the same as this article https://qiita.com/inetcpl/items/ee27a44db3fed48620a3.

    Why not try importing it inside a function?

    datetime.datetime.strptimeThe body of_strptimeBecause it is defined in the module called
    In the module to read the redash settings_strptimeMay need to be added.