Querying a database and storing into a data structure in Python

64 views Asked by At

I haven't been able to find much on this topic, so I would really like some help with the actual code to achieve this task. Preferably, use Pandas for the data structure and Python for the language. Assume a list of first names(Sally, Mike, etc) is inputted and you want to query this list from a database of first and last names(Sally Smith, Mike Miller, etc). Based upon last names already given, we want to modify this text file to only include the first names that are present in the other database.

1

There are 1 answers

0
JonD On

Without information about the type of DB you are using, I'm assuming it accepts SQL queries and you can connect from Python.

If those two conditions are satisfied, I would suggest trying Pandas' built-in query:

http://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_sql.html