Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readme out of date with metadata function? #328

Open
sam-hoffman opened this issue Jun 5, 2023 · 1 comment
Open

readme out of date with metadata function? #328

sam-hoffman opened this issue Jun 5, 2023 · 1 comment
Assignees
Labels
api: spanner Issues related to the googleapis/python-spanner-sqlalchemy API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@sam-hoffman
Copy link

sam-hoffman commented Jun 5, 2023

Environment details

  • Programming language: Python
  • OS: Mac OS 13.2.1
  • Language runtime version: 3.9.16
  • Package version: sqlalchemy 2.0.15, sqlalchemy-spanner 1.6.2

Steps to reproduce

Following the directions in the README, I wrote the following:

from sqlalchemy import create_engine, Table
from sqlalchemy.schema import MetaData

engine = create_engine(
    f"spanner+spanner:///projects/{project}/instances/{instance}/databases/{database}"
)
        metadata = MetaData(bind=engine)

and got the error:

    metadata = MetaData(bind=engine)
TypeError: __init__() got an unexpected keyword argument 'bind'

It seems the README might be out of date - what is the new way of connecting to tables? I was hoping to insert data.

@sam-hoffman sam-hoffman added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Jun 5, 2023
@product-auto-label product-auto-label bot added the api: spanner Issues related to the googleapis/python-spanner-sqlalchemy API. label Jun 5, 2023
@alexjolig
Copy link

For a fix, you should remove the bind parameter from Metadata instance and add it to your main action method. E.g: for creating a table do this:

metadata = MetaData()

table = Table(
    table_id,
    metadata,
    Column("user_id", Integer, primary_key=True),
    Column("user_name", String(16), nullable=False),
)
table.create(bind=engine)

@asthamohta asthamohta assigned ankiaga and unassigned asthamohta and ankiaga Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the googleapis/python-spanner-sqlalchemy API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

4 participants