Advertisement
12311k

Untitled

Mar 11th, 2020
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. #!/usr/bin/python
  2. import pandas as pd
  3. from sqlalchemy import create_engine
  4.  
  5. db_config = {'user': 'my_user',
  6. 'pwd': 'my_user_password',
  7. 'host': 'localhost',
  8. 'port': 5432,
  9. 'db': 'games'}
  10. connection_string = 'postgresql://{}:{}@{}:{}/{}'.format(db_config['user'],
  11. db_config['pwd'],
  12. db_config['host'],
  13. db_config['port'],
  14. db_config['db'])
  15.  
  16. engine = create_engine(connection_string)
  17.  
  18. query = ''' SELECT * FROM data_raw '''
  19.  
  20. data_raw = pd.io.sql.read_sql(query, con=engine, index_col='game_id')
  21. print(data_raw.info())
  22. print(data_raw.head(5))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement