{"id":10081,"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.","status":"abandoned","version":"0.10.2","language":"en","source_language":"en","source_url":"https://github.com/googleapis/python-bigquery-sqlalchemy","tags":["sqlalchemy","bigquery","google-cloud","database-connector","deprecated","obsolete","abandoned"],"install":[{"cmd":"pip install pybigquery","lang":"bash","label":"Install Obsolete PyBigQuery"}],"dependencies":[{"reason":"Core dependency for any SQLAlchemy dialect.","package":"sqlalchemy","optional":false},{"reason":"Underlying BigQuery client library used for API calls.","package":"google-cloud-bigquery","optional":false}],"imports":[{"note":"PyBigQuery registers itself as an SQLAlchemy dialect; direct imports from `pybigquery` itself are not typically used by the end-user.","symbol":"create_engine","correct":"from sqlalchemy import create_engine"}],"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."},"warnings":[{"fix":"Immediately plan and execute migration of your project to `google-cloud-bigquery-sqlalchemy`. Update your `requirements.txt` and review any specific BigQuery features used, as API details or supported functionalities may differ slightly or be expanded in the successor library.","message":"PyBigQuery (version 0.10.2) is **obsolete and no longer maintained**. It has critical limitations, known issues, and security vulnerabilities that will not be addressed. All users must migrate to the actively maintained successor, `google-cloud-bigquery-sqlalchemy`.","severity":"breaking","affected_versions":"<=0.10.2"},{"fix":"If absolutely necessary to use PyBigQuery, confine your environment to Python 3.9 or earlier. The recommended long-term fix is to migrate to `google-cloud-bigquery-sqlalchemy`, which supports modern Python versions.","message":"PyBigQuery only officially supports Python versions `<3.10`. Attempting to use it with Python 3.10, 3.11, or newer will highly likely lead to `ModuleNotFoundError`, `ImportError`, or other runtime compatibility issues due to unmaintained dependencies.","severity":"gotcha","affected_versions":"<=0.10.2"},{"fix":"Use SQLAlchemy 1.x API patterns if stuck with PyBigQuery. However, `google-cloud-bigquery-sqlalchemy` provides full SQLAlchemy 2.0 compatibility and is the recommended solution.","message":"PyBigQuery does not support SQLAlchemy 2.0 style usage. Its last release predates SQLAlchemy 2.0 by several years, meaning it lacks features like 2.0-specific connection and execution patterns.","severity":"gotcha","affected_versions":"<=0.10.2"},{"fix":"Always verify the package name you `pip install` against the documentation you are consulting. The GitHub repository linked from `pybigquery`'s PyPI page is for `google-cloud-bigquery-sqlalchemy`.","message":"The PyPI project page for `pybigquery` points its GitHub source URL to the repository of its *successor*, `googleapis/python-bigquery-sqlalchemy`. This can cause significant confusion, making users believe they are looking at the source or issue tracker for `pybigquery` when it's actually for the modern library.","severity":"gotcha","affected_versions":"<=0.10.2"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Downgrade your Python environment to 3.9 or earlier, or (strongly recommended) migrate your project to use `google-cloud-bigquery-sqlalchemy`.","cause":"The Python environment version is incompatible with the outdated `pybigquery` library.","error":"This application is running on Python 3.10.x (or newer), but pybigquery only officially supports up to 3.9.x."},{"fix":"Ensure `pybigquery` is correctly installed in your active environment: `pip install pybigquery`. If the problem persists, try `pip install --force-reinstall pybigquery`.","cause":"The `pybigquery` package (which registers the 'bigquery' dialect for SQLAlchemy) is not installed, or its installation is corrupted.","error":"sqlalchemy.exc.NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:bigquery"},{"fix":"Ensure you are using SQLAlchemy 1.x API patterns (e.g., `connection.execute(text(...))`). However, this is a strong indication that migration to `google-cloud-bigquery-sqlalchemy` is overdue for full SQLAlchemy 2.0 support.","cause":"Attempting to use SQLAlchemy 2.0 specific API patterns with the older PyBigQuery dialect, which lacks SQLAlchemy 2.0 compatibility.","error":"AttributeError: 'LegacyConnection' object has no attribute 'execute' (or similar SQLAlchemy 2.0 API errors)"},{"fix":"Verify the `project_id` and `dataset_id` in your connection string. Confirm your Google Cloud credentials (e.g., `GOOGLE_APPLICATION_CREDENTIALS` environment variable or `gcloud auth application-default login`) have 'BigQuery Data Viewer' and 'BigQuery Job User' roles for the specified project and dataset.","cause":"The specified BigQuery project ID or dataset ID in the SQLAlchemy connection string is incorrect, or the authenticated Google Cloud user/service account lacks necessary permissions.","error":"google.api_core.exceptions.NotFound: 404 Not Found: Dataset 'your_dataset' was not found in project 'your-gcp-project-id'."},{"fix":"PyBigQuery is a SQLAlchemy dialect plugin. You generally don't import directly from it. Instead, you import `create_engine` from `sqlalchemy` and use a `bigquery://` connection string. The `pybigquery` package only needs to be installed to register the dialect.","cause":"Users attempting to directly import modules from within the `pybigquery` package, often misinterpreting how SQLAlchemy dialects are integrated.","error":"No module named 'pybigquery.sqlalchemy' (when trying to import)"}]}