WRDS library and SQL?

1.3k Views Asked by At

I am using the WRDS library to connect to the WRDS databases through Spyder. I import wrds. According to the WRDS website, a query should look like this: 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)

However, I get this error: AttributeError: module 'wrds' has no attribute 'sql'

1

There are 1 best solutions below

1
On

Did you name your python script 'wrds.py'? This may explain why python does not find the .sql.

In my case the following works:

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')