I am trying to create an sqlite database with pandas.
I am able to save the data with:
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
engine = create_engine(path, echo=False)
df_flows.to_sql('flows', engine, if_exists='append', index=False, index_label='First')
and I can read it back with
df = pd.read_sql("SELECT * FROM flows WHERE First>1504101810 AND First<1504105409", engine)
The data is on disk but I think the indexing is not working properly as:
In [22]: from sqlalchemy.engine import reflection
In [23]: insp = reflection.Inspector.from_engine(engine)
In [24]: insp.get_indexes('flows')
Out[24]: []
Now I have 2 questions:
1) Why the column First does not appear with insp.get_indexes('flows')
2) How can I add 1 or more indexes to the database that I have created.
EDIT:
This is the structure of the data frame
In [25]: df_flows.dtypes
Out[25]:
Protocol object
Src object
SrcPort float64
Dst object
DstPort float64
Group ID int64
Port object
VPort int64
IP TOS object
VLAN ID float64
VLAN Pri float64
MPLS Exp float64
Application object
Packets int64
Messages int64
Bytes int64
First int64
Last int64
SrcSubnet object
DstSubnet object
dtype: object