{"library":"pybigquery","title":"PyBigQuery (OBSOLETE)","description":"PyBigQuery is an **obsolete** SQLAlchemy dialect for Google BigQuery. It is no longer actively maintained and should not be used for new projects. The last version released was 0.10.2, in 2019. Users are strongly advised to migrate to `google-cloud-bigquery-sqlalchemy` (PyPI package `google-cloud-bigquery-sqlalchemy`, GitHub repository `googleapis/python-bigquery-sqlalchemy`) which is the actively maintained and modern successor.","language":"python","status":"abandoned","last_verified":"Fri Apr 17","install":{"commands":["pip install pybigquery"],"cli":null},"imports":["from sqlalchemy import create_engine"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nfrom sqlalchemy import create_engine, text\n\n# Ensure GOOGLE_APPLICATION_CREDENTIALS points to your service account key file\n# or use `gcloud auth application-default login` for Application Default Credentials.\n# Replace 'your-gcp-project-id' and 'your_dataset' with actual values or set env vars.\nproject_id = os.environ.get('BIGQUERY_PROJECT_ID', 'your-gcp-project-id')\ndataset_id = os.environ.get('BIGQUERY_DATASET_ID', 'your_dataset')\n\nif project_id == 'your-gcp-project-id':\n    print(\"WARNING: Set BIGQUERY_PROJECT_ID env var or replace 'your-gcp-project-id'.\")\nif dataset_id == 'your_dataset':\n    print(\"WARNING: Set BIGQUERY_DATASET_ID env var or replace 'your_dataset'.\")\n\ntry:\n    # Connect using the 'bigquery' dialect provided by pybigquery\n    # Note: For production, ensure credentials are set securely.\n    engine = create_engine(f\"bigquery://{project_id}/{dataset_id}\")\n\n    with engine.connect() as connection:\n        # Example query (replace with your specific table/data)\n        # Note: 'text()' is required for string-based SQL statements in SQLAlchemy 1.4+/2.0.\n        result = connection.execute(text(\"SELECT 1 as num, 'hello' as str\"))\n        for row in result:\n            print(f\"Retrieved row: num={row.num}, str='{row.str}'\")\n\n    print(\"Successfully connected to BigQuery using PyBigQuery (obsolete).\")\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n    print(\"Troubleshooting hint: Check BigQuery project/dataset IDs, credentials, and Python version.\")\n    print(\"RECOMMENDATION: Migrate to 'google-cloud-bigquery-sqlalchemy' for active support.\")","lang":"python","description":"This quickstart demonstrates establishing a connection to Google BigQuery using the obsolete PyBigQuery dialect with SQLAlchemy. It relies on standard Google Cloud authentication. This code is provided for historical reference; users should migrate to `google-cloud-bigquery-sqlalchemy` for any new development or maintenance.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}