如何在 python 中使用 SQLSOUP 从模式/表中获取字典中的列名和类型?使用 MySQLDB,我可以创建游标并使用 cursor.description。 sqlsoup 有一些等价物吗?
最佳答案
根据documentation :
A Table object can be instructed to load information about itself from the corresponding database schema object already existing within the database. This process is called reflection. In the most simple case you need only specify the table name, a MetaData object, and the autoload=True flag. If the MetaData is not persistently bound, also add the autoload_with argument:
>>> messages = Table('messages', meta, autoload=True, autoload_with=engine)
>>> [c.name for c in messages.columns]
['message_id', 'message_name', 'date']
关于python - 如何在 python 的 sqlsoup 中获取模式的列名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16467386/