Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • Python Bigquery Connection Using Google BigQuery API Key and InsertQuery?

    • 0
    • 0
    • 0
    • 2
    • 0
    • 0
    • 0
    • 857
    Answer it

    Hello everyone,

    I need help to insert data into bigquery using python. I am trying to make connection using bigquery API key using this method.

    service= build('bigquery', 'v2', developerKey='XXXXXXXXXXXXXXXXX')
    print service

    I am not able to find the insert method. can anyone please help me to do this work.

    I had also used pandas dataframe to insert. I successfully insert but when I use it in cron on window server it dosesn't works.


    I had used this below function for inserting dataframe:

    my_dataframe.to_gbq('fb_raw_data.audience_size', 'XXXXXXXXXXXX', if_exists='replace', private_key='C:\Users\Vikas Chauhan\Desktop\contact\New folder\pCloud Project 1-d06466501680.json')


 2 Answer(s)

  • Hi Vikas,
    I think you can check your file code is similar as like below if yes then you can use..
    from distutils.util import convert_path
    from setuptools import find_packages
    from setuptools import setup
    ds = {}
    version_path = convert_path('bigquery/')
    with open(test_path) as test_file:
        exec(, ds)
    setup_args = dict(
        description='test Python client for interacting with Google BigQuery.',
        author='Tyler Treat',
            'Development Status ::4 - Production/Stable or not',
            'Environment :: Web Environment',
            'Intended Audience :: Developers',
            'Operating System :: OS Independent',
            'Programming Language :: Python',
    if __name__ == '__main__':
  • I think this is use full for you and also please check this link

    query_results = client.run_sync_query("""write here create query;""")
    query_results.test = False
Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: