Skip to content

Commit

Permalink
wip: bigquery model
Browse files Browse the repository at this point in the history
  • Loading branch information
phenobarbital committed Jul 8, 2024
1 parent c57029d commit 8b5e9b6
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions asyncdb/drivers/bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,26 +617,14 @@ async def _insert_(self, _model: Model, **kwargs): # pylint: disable=W0613
print('INSERT > ', table, source, type(source))
for k,v in source.items():
print(f"{k} = {v}", type(v))
# job = self._connection.insert_rows(
# table,
# [source],
# )
# print('JOB > ', job)
dataset_ref = self._connection.dataset(_model.Meta.schema)
table_ref = dataset_ref.table(_model.Meta.name)
table = bq.Table(table_ref)

job_config = bq.LoadJobConfig(
source_format=bq.SourceFormat.NEWLINE_DELIMITED_JSON,
)
job = await self._thread_func(
self._connection.load_table_from_json,
[source],
errors = self._connection.insert_rows_json(
table,
job_config=job_config
[source]
)
row = job.result()
print('ROW > ', row)
print('ROW > ', errors)
# get the row inserted again:
condition = " AND ".join(
[f"{key} = :{key}" for key in _filter]
Expand Down

0 comments on commit 8b5e9b6

Please sign in to comment.