Home Publications Certifications LinkedIn GitHub Email

Practicing SQL without a database

SQL is pretty simple to learn, but one issue I face is what to do if I want to try out something but I don't have a database to access.

Seems pretty silly to set up a database, a connection, then put in a table, just to try out some SQL commands.

There are online SQL platforms one could use, but with those you can't choose the data you want.


Luckily, there are ways of using R or Python to convert a dataset into an SQL database hosted locally.

The IBM data science specialization has a course that deals with this in Python, but that requires using an older version of SQLAlchemy, which I had trouble installing and getting to work.

But I did find a working R version using the "RSQLite" and "DBI" package


Using those, I converted the iris dataset into a "SQL database" that one can run standard SQL queries from.

Some common SQL commands on the iris dataset is given here


One can go deeper into joins and subqueries, but to be honest, I never had a case where I wanted to do that in SQL, particularly given that you would want to use the output in some way later, e.g. for stats or visualizations.

Always preferred to load in the SQL data into R or Python, can do the analysis from there. Makes for cleaner and more readable code I feel, particularly in the case of sub-queries.