Created
          March 9, 2012 13:24 
        
      - 
      
 - 
        
Save mvaz/2006493 to your computer and use it in GitHub Desktop.  
    Example of executing and reading a query into a pandas dataframe
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import cx_Oracle | |
| import pandas | |
| connection = cx_Oracle.connect('username/pwd@host:port/dbname') | |
| def read_query(connection, query): | |
| cursor = connection.cursor() | |
| try: | |
| cursor.execute( query ) | |
| names = [ x[0] for x in cursor.description] | |
| rows = cursor.fetchall() | |
| return pandas.DataFrame( rows, columns=names) | |
| finally: | |
| if cursor is not None: | |
| cursor.close() | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
It works also for jaydebeapi for fetching data from hive using JDBC driver. Thanks