Skip to content

SQLalchemy interface in pandas.io #191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wesm opened this issue Oct 2, 2011 · 2 comments
Closed

SQLalchemy interface in pandas.io #191

wesm opened this issue Oct 2, 2011 · 2 comments
Labels
Enhancement IO Data IO issues that don't fit into a more specific label IO SQL to_sql, read_sql, read_sql_query
Milestone

Comments

@wesm
Copy link
Member

wesm commented Oct 2, 2011

No description provided.

@wesm
Copy link
Member Author

wesm commented Dec 26, 2011

from "SQLAlchemy bridge" thread on pystatsmodels

def getattr_recursively(object, name):
   """Same as getattr() built-in, but first split *name* into parts
and
   descend into object hierarchy.

   Return *None* if any of the attributes along the way is *None*.

   """

   current_object = object
   for n in name.split('.'):
       try:
           current_object = getattr(current_object, n)
       except AttributeError as err:
           if current_object is None:
               break
           else:
               raise err
   return current_object


columns = ('age_id', 'is_working.value')
list_of_lists = [[getattr_recursively(row, col) for col in columns]
for row in qry_result]
data = DataFrame.from_records(list_of_lists, columns=columns)

@jreback
Copy link
Contributor

jreback commented Sep 22, 2013

closing in favor of master issue #4163

@jreback jreback closed this as completed Sep 22, 2013
dan-nadler pushed a commit to dan-nadler/pandas that referenced this issue Sep 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement IO Data IO issues that don't fit into a more specific label IO SQL to_sql, read_sql, read_sql_query
Projects
None yet
Development

No branches or pull requests

2 participants