Skip to main content

A command line interface to the Google Ads Query Language (GAQL). Run with `gaql` or `gaql-tools`

Project description

GAQL CLI

A CLI for sending GoogleAds queries

Usage

Installing

pip install gaql

pipx install gaql (recommended)

Querying

The default mode. Runs either as a REPL, or as a one off command

- gaql [ACCOUNT_ID] - run in REPL mode
- gaql [ACCOUNT_ID] [WORDS*] - run a single query. Note dependening on your shell you may need to quote some queries if you run like this.

flags:
--help show the help message; basically the below
-f|--format <csv|json|jsonl|proto> specify an output format
-o|--output <file> specify an output file. Based on the extension, format is inferred. Non REPL usage only

Examples, using 1-000-000 as our demo account id:

# opens a REPL with json lines as the output format
gaql -f jsonl 1-000-000

# runs the query against the given account, outputting to the terminal the results as json lines
gaql -f jsonl 1-000-000 'SELECT campaign.id FROM campaign'

# runs the query against the given account, outputting to 'campaigns.jsonl' the result as json lines
gaql -o campaigns.jsonl 1-000-000 'SELECT campaign.id FROM campaign'

tip: the autocomplete will return only valid fields for the selected entity if you fill out the FROM <entity> part first.

Other tools

Used for useful common queries. Currently only supports getting all accounts under an MCC, to help when managing multiple accounts. The MCC is taken from the login_customer_id field.

  • gaql-tools queries clients

Notes

  • credentials come from the environment > the google .yaml file > a user provided credential file
  • credentials, settings, and history are stored in ./config/gaql/*. The credential file will only be present if you create it through a prompt (i.e you aren't using the ENV, or the YAML file Google specifies)

Ideas / TODO

  • tables as an output format
  • autocomplete for account ids (with caching)

Development

We're using poetry for local development, package management, and publishing. pyenv is recommended for Python version management, and pipx for installation.

Build commands:

make develop - install a development version. run via `poetry run gaql <args>`
make publish - build and distribute to PyPi
make clean   - remove the existing build files
make format  - run black over the code
make lint    - lint and format the code

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gaql-1.0.1.tar.gz (45.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gaql-1.0.1-py3-none-any.whl (49.2 kB view details)

Uploaded Python 3

File details

Details for the file gaql-1.0.1.tar.gz.

File metadata

  • Download URL: gaql-1.0.1.tar.gz
  • Upload date:
  • Size: 45.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/2.7.10 Darwin/18.7.0

File hashes

Hashes for gaql-1.0.1.tar.gz
Algorithm Hash digest
SHA256 35f88bc4e00d5187f5df7f0f87332b0658d36d561606fd2e58a2d815e19b9c11
MD5 483350631f4ca4d3dd2af9686e2364d4
BLAKE2b-256 99f7b104e2bfd0334f1e431b5144e715ea2858308a9a6413682c2d7e42f04f4a

See more details on using hashes here.

File details

Details for the file gaql-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: gaql-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 49.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/2.7.10 Darwin/18.7.0

File hashes

Hashes for gaql-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f74d0ef0908bab35ae6955402af62b468b79e105f8cdc618a51122d30ca1318a
MD5 732efbed5bf0c82b563fc0bb39e683fe
BLAKE2b-256 8c8dd17b4b19c2b9dadf14631938b54f695664a97e2142f7a21ddef8d07af19f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page