Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit07b805c

Browse files
committed
Table comment identification fix -test
1 parenta799ee7 commit07b805c

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

‎src/databricks/sqlalchemy/dialect/__init__.py‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,36 @@ def has_table(self, connection, table_name, schema=None, **kwargs) -> bool:
302302
else:
303303
raisee
304304

305+
defget_table_comment(self,connection,table_name,schema=None,**kw):
306+
r"""Return the "comment" for the table identified by `table_name`.
307+
308+
Given a string `table_name` and an optional string `schema`, return
309+
table comment information as a dictionary with this key:
310+
311+
returns:
312+
dict = {"text": "Table comment here"}
313+
314+
"""
315+
COMMENT=2
316+
schema_str=schema
317+
table_name_str=table_name
318+
319+
withself.get_driver_connection(
320+
connection
321+
)._dbapi_connection.dbapi_connection.cursor()ascur:
322+
sql_str="""SELECT table_schema, table_name, comment
323+
FROM information_schema.tables
324+
WHERE table_schema = '{schema}'
325+
AND table_name = '{table}';""".format(
326+
schema=schema_str,
327+
table=table_name_str
328+
)
329+
# TODO: Add if scenario for None schema
330+
data=cur.execute(sql_str).fetchall()
331+
_comment= [i[COMMENT]foriindata]
332+
333+
return {"text":_comment}
334+
305335
@reflection.cache
306336
defget_schema_names(self,connection,**kw):
307337
# Equivalent to SHOW DATABASES

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp