Ask Your Question
3

What is the process of using SQLAlchemy ORM and cloud spanner to read rows as model objects?

asked 2021-05-07 11:00:00 +0000

woof gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2022-03-20 17:00:00 +0000

ladyg gravatar image
  1. Define your models (Python classes) using SQLAlchemy's declarative syntax.
  2. Create a SQLAlchemy engine that's configured to connect to your Cloud Spanner instance.
  3. Create a session using the SQLAlchemy sessionmaker, passing in the engine you created in step 2.
  4. In your code, query the session to retrieve rows from the database using standard SQLAlchemy syntax.
  5. SQLAlchemy will automatically map the row data to instances of your model classes, giving you rich, object-oriented access to your data.
  6. Use the model instances to manipulate the data and perform any necessary calculations or transformations.
  7. When you're ready to save your changes back to the database, use the session to commit the changes or rollback if there were any errors.
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-05-07 11:00:00 +0000

Seen: 12 times

Last updated: Mar 20 '22