Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Override table using bq command line

I have a Python script (shown below) that runs the query in 'query.txt' and uploads it to google big query. This script has to run every 5 minutes. First time it does correctly, but for the second time, it throws the error "table already exists". I have to override the table if it already exists. I do not find any override option in bq help. Any help would be appreciated.

commandStr = "type C:\Users\sridevibaskaran\query.txt | bq query --destination_table geotab-bigdata-test:TestSridevi.DeviceCarrier_%s -n 1" %(dateToday1)
os.system(commandStr)
print commandStr
like image 889
user3447653 Avatar asked Jan 25 '26 08:01

user3447653


1 Answers

run bq help query and check replace flag

--[no]replace: If true, erase existing contents before loading new data. (default: 'false')

like image 173
Mikhail Berlyant Avatar answered Jan 27 '26 21:01

Mikhail Berlyant



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!