我正在使用 pd.read_sql 和 sqlserver 从特定表中获取列名。然而,熊猫只返回一个空数据框,而我从 ssms 获得有效结果。这是我正在使用的代码:
query = f'''select * from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = 'Table_name'
'''
df_output = pd.read_sql(query, connection)
结果如下:
Empty DataFrame
Columns: [TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME, ORDINAL_POSITION, COLUMN_DEFAULT, IS_NULLABLE, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH, NUMERIC_PRECISION, NUMERIC_PRECISION_RADIX, NUMERIC_SCALE, DATETIME_PRECISION, CHARACTER_SET_CATALOG, CHARACTER_SET_SCHEMA, CHARACTER_SET_NAME, COLLATION_CATALOG, COLLATION_SCHEMA, COLLATION_NAME, DOMAIN_CATALOG, DOMAIN_SCHEMA, DOMAIN_NAME]
Index: []
提前致谢