{"id":47707952,"url":"https://github.com/amirdor/pbq","last_synced_at":"2026-04-02T18:06:23.984Z","repository":{"id":46083740,"uuid":"214995763","full_name":"amirdor/pbq","owner":"amirdor","description":"python BiqQuery driver for easy access","archived":false,"fork":false,"pushed_at":"2022-12-26T20:59:14.000Z","size":34,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-03-21T23:18:03.495Z","etag":null,"topics":["bq-cli"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/amirdor.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-10-14T08:59:22.000Z","updated_at":"2020-01-21T08:44:30.000Z","dependencies_parsed_at":"2023-01-31T01:45:53.276Z","dependency_job_id":null,"html_url":"https://github.com/amirdor/pbq","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/amirdor/pbq","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amirdor%2Fpbq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amirdor%2Fpbq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amirdor%2Fpbq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amirdor%2Fpbq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amirdor","download_url":"https://codeload.github.com/amirdor/pbq/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amirdor%2Fpbq/sbom","scorecard":{"id":189675,"data":{"date":"2025-08-11","repo":{"name":"github.com/amirdor/pbq","commit":"7e83a461c10d1d7284ccfb0ad278285be57d859d"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Code-Review","score":0,"reason":"Found 0/26 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"10 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-496j-2rq6-j6cc","Warn: Project is vulnerable to: GHSA-6628-q6j9-w8vg","Warn: Project is vulnerable to: GHSA-9hxf-ppjv-w6rq","Warn: Project is vulnerable to: GHSA-cfgp-2977-2fmm","Warn: Project is vulnerable to: PYSEC-2017-101","Warn: Project is vulnerable to: PYSEC-2020-73","Warn: Project is vulnerable to: PYSEC-2024-161","Warn: Project is vulnerable to: PYSEC-2021-437 / GHSA-5xp3-jfq3-5q8x","Warn: Project is vulnerable to: PYSEC-2023-228 / GHSA-mq26-g339-26xf","Warn: Project is vulnerable to: PYSEC-2022-43017 / GHSA-qwmp-2cf2-g9g6"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-16T20:23:43.734Z","repository_id":46083740,"created_at":"2025-08-16T20:23:43.735Z","updated_at":"2025-08-16T20:23:43.735Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31312744,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T12:59:32.332Z","status":"ssl_error","status_checked_at":"2026-04-02T12:54:48.875Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bq-cli"],"created_at":"2026-04-02T18:06:20.213Z","updated_at":"2026-04-02T18:06:23.968Z","avatar_url":"https://github.com/amirdor.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"PBQ\n===\n\n[![PyPI version](https://badge.fury.io/py/pbq.svg)](https://badge.fury.io/py/pbq)\n\n[![Build Status](https://travis-ci.org/amirdor/pbq.svg?branch=master)](https://travis-ci.org/amirdor/pbq)\n\n[![Documentation Status](https://readthedocs.org/projects/pbq/badge/?version=latest)](https://pbq.readthedocs.io/en/latest/?badge=latest)\n\npython BiqQuery driver for easy access\n\n\n\nInstalling\n----------\n\nTo start using this package run:\n\n``` bash\n$ pip install pbq\n```\n\nFor development use, and local testing run:\n\n``` bash\n$ python setup.py install\n```\n\n\n\nDependency\n----------\n\n**bq Command-Line Tool**\n\nInstall bq cli -- the package is running bq cli in the background\n\n``` bash\nhttps://cloud.google.com/sdk/docs/\n```\n\nafter installation on a new terminal write:\n\n``` bash\n$ bq init\n$ gcloud auth application-default login\n```\n\nif you don't want to install bq cli you can run the package with the\nservice account key\n\nall you need to do it to define an environment variable like this:\n\n``` bash\n$ export GOOGLE_APPLICATION_CREDENTIALS=\"/home/user/Downloads/[FILE_NAME].json\"\n```\n\nUsage\n=====\n\nImport this package to your project and you are ready to go\n\n``` python\nfrom pbq import PBQ\nfrom pbq import Query\n```\n\n\n\nPBQ\n---\n\nThis class can have generic functions for big query manipulation and\nsave queries to tables.\n\n### some usages:\n\n#### Download table to CSV\n\n``` python\nfrom pbq import PBQ\nfrom pbq import Query\n\n# read sql file and format the query from file to string without parameters\nquery = Query.read_file('queries/query.sql')\n\n# init the query builder\npbq = PBQ(query)\n\n#run the query and get csv\npbq.to_csv('file.csv', save_query=True, **{'table': 'table', 'dataset': 'dataset'})\n```\n\nwhen setting save\\_query=True it means that you want to save your query\nto a table, and you need to send dictionary with the table name and\ndataset name.\n\nDownload table to pandas DataFrame\n\n``` python\nfrom pbq import PBQ\nfrom pbq import Query\n\n# read sql file and format the query from file to string without parameters\nquery = Query.read_file('queries/query.sql')\n\n# init the query builder\npbq = PBQ(query)\n\n#run the query and get dataframe\npbq.to_dataframe()\n```\n\n#### Simply run your query \n\n``` python\nfrom pbq import PBQ\nfrom pbq import Query\n\n# read sql file and format the query from file to string without parameters\nquery = Query.read_file('queries/query.sql')\n\n# init the query builder\npbq = PBQ(query)\n\n#run the query if you want to write insert query or alter table for example.\npbq.run_query()\n```\n\n\n#### Save query to a table\n\n``` python\nfrom pbq import PBQ\nfrom pbq import Query\n\n# read sql file and format the query from file to string without parameters\nquery = Query('select * from table')\n\n# init the query builder\npbq = PBQ(query)\npbq.save_to_table('table_name', 'dataset_name', 'project_name', replace=True, partition='20190910')\n```\n\nWhen setting replace=True it will override the table as long as the\ntable is not partitioned, if partitioned it will overwrite the\npartition.\n\npartition format is `YYYYMMDD`\n\n\n\n#### upload DataFrame to a table\n\n``` python\nimport pandas as pd\nfrom pbq import Query, PBQ\ndf = pd.DataFrame()\nPBQ.save_dataframe_to_table(df, 'table', 'dataset', 'project_id', partition='20191013', replace=False)\n```\n\n\n\nQuery\n-----\n\nThis class will format your query, check validation and return the price\nof the query\n\n### some usages:\n\n#### generate the query object with a simple query\n\n``` python\nfrom pbq import Query\nquery = Query(\"select * from table\")\n```\n\n#### get query price\n\n``` python\nfrom pbq import Query\nquery = Query(\"select * from table\")\nprint(\"the query price:\", query.price)\n# the query price: 0.312\n```\n\n#### validate query\n\n``` python\nfrom pbq import Query\nquery = Query(\"select * from table\")\nif not query.validate():\n    raise RuntimeError(\"table not valid\")\n```\n\n#### query with parameters\n\n``` python\nfrom pbq import Query\nquery = Query(\"select * from table where user_id={user_id}\", parameters={'user_id': 123})\nprint(query.query)\n# select * from table where user_id=123\n```\n\n#### read the query from file with parameters\n\n``` python\nfrom pbq import Query\nquery = Query.read_file('file_path.sql', parameters={'user_id':123})\nprint(query.query)\n# select * from table where user_id=123\n```\n\n\n-   Free software: MIT license\n-   Documentation: \u003chttps://pbq.readthedocs.io\u003e.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famirdor%2Fpbq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famirdor%2Fpbq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famirdor%2Fpbq/lists"}