Python Forum
Sqlalchemy accepting ISO 8601
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sqlalchemy accepting ISO 8601
#1
I have a csv im trying to upload to a database.

Database uses flask - sqlalchemy.

Collects row from csv.
date_time_store = row['date_time']
Uploads row
query = tintin_store(date_time = date_time_store
Cell is formatted like so
 date_time = db.Column(db.DATETIME, nullable=False, primary_key=True)
My timezone in the csv is in ISO 8601: e.g. 2018-07-27T11:19:40+01:00

the cell accepts date time in the 'standard' form : 2018/07/27 11:19:40

I can not find an easy way to convert the ISO 8601 into a format my sqlalchemy table will accept. I dont really care about UTC in this project so if needs to be removed then it can be, but the data entry format has to be ISO 8601 and i would ideally like to at least keep the utc saved somewhere. Even if this means introducing a new column and inserting it as a string in there.

So far i have tried: 
date_time_store= dateutil.parser.parse(date_time_store)
date_time_store= dateutil.parser.parse(date_time_store).timetuple()
date_time_store= time.strptime(date_time_store, "%Y-%m-%dT%H:%M:%S")
date_time_store= time.strptime(date_time_store, "%Y-%m-%dT%H:%M:%S%z")
date_time_store= time.strptime(date_time_store, "%Y-%m-%dT%H:%M:%S%Z")
All of which have failed if required can probably recode to get the tracebacks of each failure. Anyone know of a solution to my somewhat basic problem. ?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Accepting inputs str vs int lbtdne 2 1,829 May-14-2020, 01:45 PM
Last Post: lbtdne
  Problem with accepting multiple string inputs Ryan_Todd 5 2,948 Jan-22-2020, 06:12 PM
Last Post: buran
  signal.itimer() not accepting keyword arguments Skaperen 2 2,248 Dec-19-2019, 12:14 AM
Last Post: Skaperen
  Accepting strings as arguments when slicing a string? (Ziyad Yehia on Udemy) Drone4four 4 3,793 Aug-23-2019, 07:59 PM
Last Post: Drone4four
  MySQL not accepting utf8mb4. Warning 3719 jonesin1974 0 4,770 Jun-21-2018, 03:09 AM
Last Post: jonesin1974
  if loop is not accepting && A_Embedded 2 2,751 Apr-22-2018, 02:24 PM
Last Post: A_Embedded

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020