WRDS库和SQL?

2024-06-16 12:49:22 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用WRDS库通过Spyder连接到WRDS数据库。我导入wrds。根据WRDS网站,查询应该如下所示: result = wrds.sql('select * from dataset', 'variable')

https://wrds-web.wharton.upenn.edu/wrds/support/Accessing%20and%20Manipulating%20the%20Data/_004Python%20Programming/_001Using%20Python%20with%20WRDS.cfm

但是,我得到了这个错误:AttributeError: module 'wrds' has no attribute 'sql'


Tags: fromhttpsweb数据库sql网站resultvariable
1条回答
网友
1楼 · 发布于 2024-06-16 12:49:22

你给你的python脚本命名了吗wrds.py'? 这可以解释python为什么找不到.sql。在

在我的案例中,以下是有效的:

import wrds
db = wrds.Connection()
libraries = db.list_libraries()
library = 'compg'

tables = db.list_tables(library=library)
table = 'g_company'

result = db.raw_sql('select * from COMPG.G_COMPANY')

相关问题 更多 >