Skip to content
This repository was archived by the owner on Mar 13, 2026. It is now read-only.

Commit 63461e6

Browse files
author
Ilya Gurov
authored
feat: implement get_view_names() method (#306)
Closes #303
1 parent c376d42 commit 63461e6

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

create_test_database.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def create_test_instance():
7070
configs = list(CLIENT.list_instance_configs())
7171
if not USE_EMULATOR:
7272
# Filter out non "us" locations
73-
configs = [config for config in configs if "us-south1" in config.name]
73+
configs = [config for config in configs if "us-west1" in config.name]
7474

7575
instance_config = configs[0].name
7676
create_time = str(int(time.time()))

google/cloud/sqlalchemy_spanner/sqlalchemy_spanner.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,24 @@ def create_connect_args(self, url):
587587
{"user_agent": f"gl-{dist.project_name}/{dist.version}"},
588588
)
589589

590+
@engine_to_connection
591+
def get_view_names(self, connection, schema=None, **kw):
592+
sql = """
593+
SELECT table_name
594+
FROM information_schema.views
595+
WHERE TABLE_SCHEMA='{}'
596+
""".format(
597+
schema or ""
598+
)
599+
600+
all_views = []
601+
with connection.connection.database.snapshot() as snap:
602+
rows = list(snap.execute_sql(sql))
603+
for view in rows:
604+
all_views.append(view[0])
605+
606+
return all_views
607+
590608
@engine_to_connection
591609
def get_columns(self, connection, table_name, schema=None, **kw):
592610
"""Get the table columns description.

noxfile.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,18 +141,19 @@ def compliance_test_13(session):
141141
)
142142

143143
session.install(
144-
"pytest",
145144
"pytest-cov",
146-
"pytest-asyncio",
147145
)
148146

149147
session.install("mock")
150148
session.install("-e", ".[tracing]")
151149
session.run("pip", "install", "sqlalchemy>=1.1.13,<=1.3.24", "--force-reinstall")
152-
session.run("pip", "install", "pytest==6.2.2", "--force-reinstall")
153150
session.run("pip", "install", "opentelemetry-api<=1.10", "--force-reinstall")
154151
session.run("pip", "install", "opentelemetry-sdk<=1.10", "--force-reinstall")
155152
session.run("python", "create_test_database.py")
153+
session.run("pip", "install", "pytest==6.2.2", "--force-reinstall")
154+
session.run(
155+
"pip", "install", "pytest-asyncio<0.21.0", "--force-reinstall", "--no-deps"
156+
)
156157

157158
session.run(
158159
"py.test",

0 commit comments

Comments
 (0)