SQLite and Python

I have already written an article about using a SQLite database from R.  I was playing recently with some data, scraped from a web site to text files, that I wanted to transform into a SQLite database. I decided to do it in python, using the sqlite3 module. After a few experiments, I noticed that the SELECT queries on SQLite return a list of tuples. This can be verified as follows, the following code opens a SQLite database and creates a cursor. On this cursor a query is run to return all the SQL statements necessary to drop all tables, one after the other :

The result shall be this:

That’s OK. However, it would be nice if I could get them in a Pandas dataframe… how nice that would be. In fact it is very easy, as Pandas supports it natively. I can pass a SQL query directly to Pandas using the read_sql_query and that shall return to me a nice Pandas dataframe. This is done as follows:

That’s all for the moment, in the next articles I am going to play with jupyter on Android, with the “pickles” and with the radar or spider charts!