使用SQLAlchemy检查雪花表上的列时,列注释不可见。你知道吗
pip install snowflake-sqlalchemy
测试
import sqlalchemy
# set up the connection
snowflake_conn = '<your-connection-string-here>'
engine = sqlalchemy.create_engine(snowflake_conn)
# create a table for testing, add a column comment
engine.execute('create table public.test ("col1" text);')
engine.execute("""alter table public.test alter "col1" comment 'this is my comment'""")
# check if comment is successfully stored in the information schema
engine.execute("select comment from information_schema.columns where table_name='TEST'").fetchall()
# Output: [('this is my comment',)]
# now let's try to inspect the table
inspector = sqlalchemy.inspect(engine)
inspector.get_columns('TEST', schema='PUBLIC')
实际结果
[{'name': 'col1',
'type': VARCHAR(length=16777216),
'nullable': True,
'default': None,
'autoincrement': False,
'primary_key': False}]
预期结果
[{'name': 'col1',
'type': VARCHAR(length=16777216),
'nullable': True,
'default': None,
'comment': 'this is my comment', # <-- this is added
'autoincrement': False,
'primary_key': False}]
我检查专栏评论是做错了什么,还是这仅仅是雪花sqlalchemy中的一个bug?你知道吗
感谢您发布您的发现!你知道吗
这似乎是
snowflake-sqlalchemy
中的一个问题,我们已经开始调查这个问题,请关注这里的更新:https://github.com/snowflakedb/snowflake-sqlalchemy/issues/90我刚刚用
snowflake-sqlalchemy==1.1.18
测试了您的(准备充分的)代码,注释现在按预期返回。你知道吗相关问题 更多 >
编程相关推荐