def insert_sql(project, default_dataset, sql_path):
 client = bigquery.Client(project=project)
 with open(sql_path) as f:
  for line in f:
   line = line.strip()
   if (not line.startswith('INSERT')):
    continue
   print 'Running query: {}{}'.format(line[:60], ('...' if (len(line) > 60) else ''))
   query = client.run_sync_query(line)
   query.use_legacy_sql = False
   query.default_dataset = client.dataset(default_dataset)
   query.run()

def insert_sql ( project , default_dataset , sql_path ) : client = bigquery . Client ( project = project ) with open ( sql_path ) as f : for line in f : line = line . strip ( ) if ( not line . startswith ( 'INSERT' ) ) : continue print 'Running query: {}{}' . format ( line [ : 60 ] , ( '...' if ( len ( line ) > 60 ) else '' ) ) query = client . run_sync_query ( line ) query . use_legacy_sql = False query . default_dataset = client . dataset ( default_dataset ) query . run ( )
run all the sql statements in a sql file .