convert python sqlite db to hdf5
Question: A Pandas DataFrame can be converted to a hdf5 file like this;

`df.to_hdf('test_store.hdf','test',mode='w')`

I have an sqlite db file which has to be converted to a hdf5 file and then I
would read the hdf5 file through pandas using `pd.read_hdf`.

But first how do I convert a python sqlite db to a hdf5 file ?

EDIT:

I am aware of using the `.read_sql` method in pandas. But I would like to
convert the db to hdf5 first.


Answer: This is surprisingly simple: Use pandas!

pandas supports [reading data directly from a SQL
database](http://pandas.pydata.org/pandas-docs/stable/io.html#io-sql) into a
DataFrame. Once you've got the DataFrame, you can do with it as you wish.

Short example, taken [from the docs](http://pandas.pydata.org/pandas-
docs/stable/io.html#io-sql):

    
    
    import sqlite3
    from pandas.io import sql
    # Create your connection.
    cnx = sqlite3.connect('mydbfile.sqlite')
    
    # read the result of the SQL query into a DataFrame
    data = sql.read_sql("SELECT * FROM data;", cnx)
    
    # now you can write it into a HDF5 file
    data.to_hdf('test_store.hdf','test',mode='w')
    

