Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a List like shown below (The list has been obtained by converting a pandas dataframe to a list. The pandas dataframe is obtained from an excel):

  • L = [[3982, 36308220021, Timestamp('2017-07-01 14:10:37'), '', Timestamp('2017-07-01 14:20:48'), '', 0, 0]]

Note: L is actually a nested list with more than 5000 entries.

I am inserting the values in MySQL using python . There I have defined the column as "dateACW DATETIME" during CREATE TABLE operations. Similar column names have been defined for other Timestamp values from the list. During insertion in MySQL, it gives following error: "AttributeError: 'Timestamp' object has no attribute 'translate'". I tried using TIMESTAMP datatype instead of DATETIME. That did not help. Please help me out with explanation on whats the problem.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
157 views
Welcome To Ask or Share your Answers For Others

1 Answer

You can probably use to_pydatetime() function to convert it to datetime.

timestamp = pd.Timestamp('2017-07-01 14:10:37', tz=None)

timestamp.to_pydatetime()

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...