[Bigquery insert data error] table.insert_data() issue
See original GitHub issueI got this error while using table.insert_data(rows)
--> 246     if not value.tzinfo:
    247         value = value.replace(tzinfo=UTC)
    248     # Regardless of what timezone is on the value, convert it to UTC.
AttributeError: 'str' object has no attribute 'tzinfo'
The doc of table.insert_data() said rows is list of tuple, so this is my schema
sql_schema = [('viewer_id', 'INTEGER'),
              ('ip','STRING'),
              ('author_id', 'INTEGER'),
              ('post_id', 'STRING'),
              ('time', 'TIMESTAMP')]
And this is a test data:
[['25512',
  '126.107.92.215',
  '6524',
  '9f4047d3-7bf8-406c-823c-9803b4730fb9',
  '2015-12-14 18:29:01.245142'],
 ['24534',
  '87.13.200.79',
  '29096',
  'e09baadc-9647-4cde-9019-7c6846dfd662',
  '2015-12-14 18:29:01.245237']]
I know '2015-12-14 18:29:01.245237' is a string which doesn’t have tzinfo field.
Do I have to convert it to Datetime object every time I try to load time data into bigquery?
Do I have better options?
Thanks
Issue Analytics
- State:
- Created 8 years ago
- Comments:14 (8 by maintainers)
 Top Results From Across the Web
Top Results From Across the Web
error while inserting data to a bigquery table in google cloud?
this error message shows while i'm running a query in my big query table. I create a table called nutrient and i want...
Read more >Error messages | BigQuery - Google Cloud
This document describes error messages you might encounter when working with BigQuery, including HTTP error codes, job errors, and Google Cloud console ...
Read more >Error while inserting data to big query table - Talend Community
Hello Everyone,. Getting below error in the last insert in bigquery output. Starting job live_exercise_v1 at 01:45 30/03/2020.
Read more >POST Web service data action Problem (BigQuery)
Hi, everyone. I am trying to integrate a Web Service (Post) of BigQuery and Purecloud with data actions based on HTTPS.
Read more >OAuth 2.0 Scopes for Google APIs | Authorization
https://www.googleapis.com/auth/bigquery.insertdata, Insert data into Google BigQuery ... Administer your Cloud Bigtable tables and clusters.
Read more > Top Related Medium Post
Top Related Medium Post
No results found
 Top Related StackOverflow Question
Top Related StackOverflow Question
No results found
 Troubleshoot Live Code
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free Top Related Reddit Thread
Top Related Reddit Thread
No results found
 Top Related Hackernoon Post
Top Related Hackernoon Post
No results found
 Top Related Tweet
Top Related Tweet
No results found
 Top Related Dev.to Post
Top Related Dev.to Post
No results found
 Top Related Hashnode Post
Top Related Hashnode Post
No results found

Sorry the doc is vague:
As an example, our system test uses the schema
to create the table
and then uses rows as a list of triples
that correspond to the schema (i.e. a required string, a required integer and an optional timestamp). After does this, they are inserted with a set of row IDS:
(For the record, I wouldn’t have expected you to have looked here, just wanted to provide an example.)
datetime.datetimeobject for aTIMESTAMPschema field.sql_schemaand your “test data” were used.Thanks