0

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.

1 Answer 1

0

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()
Sign up to request clarification or add additional context in comments.

1 Comment

Actually, the list is very huge. It's a list of list with more than 5000 entries. Is there a quick way which can convert all the entries with prefixed "Timestamp ( *****)" into an appropriate entry for MySQL INSERT query.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.