From 608e0c939dd5dc07e52bf1c791a170c72b33fb78 Mon Sep 17 00:00:00 2001 From: Ilya Gurov Date: Wed, 17 Nov 2021 13:23:23 +0300 Subject: [PATCH 1/2] Update README.md --- README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/README.md b/README.md index b8c557b6..8aed0ba6 100644 --- a/README.md +++ b/README.md @@ -157,6 +157,29 @@ eng = create_engine("spanner:///projects/project-id/instances/instance-id/databa autocommit_engine = eng.execution_options(isolation_level="AUTOCOMMIT") ``` +### Query hints +Spanner dialect supports query hints, which give an ability to set additional query execution parameters ([see for more info](https://cloud.google.com/spanner/docs/query-syntax#table_hints)). Usage example: +```python +session = Session(engine) + +Base = declarative_base() + +class User(Base): + """Data model.""" + + __tablename__ = "users" + id = Column(Integer, primary_key=True) + name = Column(String(50)) + + +query = session.query(User) +query = query.with_hint( + selectable=User, text="@{FORCE_INDEX=index_name}" +) +query = query.filter(User.name.in_(["val1", "val2"])) +query.statement.compile(session.bind) +``` + ### ReadOnly transactions By default, transactions produced by a Spanner connection are in ReadWrite mode. However, some applications require an ability to grant ReadOnly access to users/methods; for these cases Spanner dialect supports the `read_only` execution option, which switches a connection into ReadOnly mode: ```python From 7e96557a3470e94956f3771e3827b873cd7e6b4a Mon Sep 17 00:00:00 2001 From: Ilya Gurov Date: Thu, 18 Nov 2021 12:08:36 +0300 Subject: [PATCH 2/2] Update README.md Co-authored-by: skuruppu --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8aed0ba6..0f741e55 100644 --- a/README.md +++ b/README.md @@ -158,7 +158,7 @@ autocommit_engine = eng.execution_options(isolation_level="AUTOCOMMIT") ``` ### Query hints -Spanner dialect supports query hints, which give an ability to set additional query execution parameters ([see for more info](https://cloud.google.com/spanner/docs/query-syntax#table_hints)). Usage example: +Spanner dialect supports [query hints](https://cloud.google.com/spanner/docs/query-syntax#table_hints), which give the ability to set additional query execution parameters. Usage example: ```python session = Session(engine)