Skip to content

Python & SQL

Why Python with SQL?

For Data Analysts and Data Scientists, Python has many advantages. A huge range of open-source libraries make it an incredibly useful tool for any Data Analyst.

We have pandas, NumPy and Vaex for data analysis, Matplotlib, seaborn and Bokeh for visualisation, and TensorFlow, scikit-learn and PyTorch for machine learning applications (plus many, many more).

With its (relatively) easy learning curve and versatility, it's no wonder that Python is one of the fastest-growing programming languages out there.

Python mysql.connector

Fetch Methods

Instead of iterating over the cursor object we can use the following methods to access one or more rows at time.

Method Description
fetchone() Returns the next row from the result set as tuple. If there are no more rows to retrieve, None is returned.
fetchmany([size]) Returns the specified number of rows (as a list of tuple) from the result set. If there are no more rows to retrieve, [] is returned. The default size is 1.
fetchall() Returns the all (or remaining) rows from the result set.