1

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'

Luboš Turek
  • 6,273
  • 9
  • 40
  • 50
st19297
  • 521
  • 1
  • 5
  • 18

1 Answers1

3

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')
Daniel
  • 304
  • 2
  • 12
  • Thanks a lot. I am not sure if I name the script WRDS.py but probably did. I will try your code. Thanks again. – st19297 Oct 28 '17 at 02:25