Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.89 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.  
  11. connection_string = 'postgresql://{}:{}@{}:{}/{}'.format(db_config['user'],
  12.                                                          db_config['pwd'],
  13.                                                          db_config['host'],
  14.                                                          db_config['port'],
  15.                                                          db_config['db'])
  16.  
  17. engine = create_engine(connection_string)
  18.        
  19. query = ''' SELECT game_id, name, platform, year_of_release
  20.            FROM data_raw
  21.        '''
  22.  
  23. data_raw = pd.io.sql.read_sql(query, con = engine, index_col = 'game_id')
  24.  
  25. print(data_raw.info())
  26. print(data_raw.head(5))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement