Skip to content

[Bigquery insert data error] table.insert_data() issue #1381

@lukaemon

Description

@lukaemon

I 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

Metadata

Metadata

Assignees

Labels

api: bigqueryIssues related to the BigQuery API.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions