MySQL DATE Calculations using INTERVAL – with examples

Recently in my day job, while developing the back-end of a reporting dashboard with PHP and MySQL, I noticed some interesting differences in DATE math calculations. The examples used in this post are purely arbitrary but stem from lessons learned, therefore, I feel they are definitely worth sharing…

[Keep reading for more SQL database and Python-centric content >>>]
Advertisements

MySQL Shell CRUD with Python: Read – with examples

In MySQL Shell CRUD with Python: Create – with examples, I visited the insert() method, demonstrating how simple it is to add new rows of data to a table using Python in the MySQL Shell. Now that the data is stored, if we want to retrieve any of it – for reading – we need to SELECT it, right? Luckily, there is a select() method available we can use in Python mode in the shell, making this operation relatively simple. But, as simple as it is, the power lies in the combinations of other similar class methods used for filtering. Interested? Keep reading… [Keep reading for more SQL database and Python-centric content >>>]

Pandas and the python os module use case – appending source file information from CSV’s.

In my day job, I use Python to automate several redundant tasks. Between the Pandas library and the CSV module, there is always something available for me to reach for. I typically process several different CSV’s each day with a planned final destination in a SQL database. While contemplating the schema design, I determined it would be best to store the actual source file information from which the data is derived, using the source files’ name and appending it to the end of each row. How did Python help me accomplish this? Continue reading to find out…

[Keep reading for more SQL database and Python-centric content >>>]

Renaming pandas DataFrame columns – with examples.

In the blog post, How to drop columns from a Pandas DataFrame – with examples., I covered examples of how to completely remove certain columns from a pandas DataFrame. But what if you need to keep the columns, yet their names are not to your liking? Perhaps you need to provide a report with meaningful column names in a CSV or Excel file? Again, pandas make this relatively simple. Let’s understand with some examples…

[Keep reading for more SQL database and Python-centric goodness >>>]

Pandas dataframe ordering with examples using sort_values().

Often times, you need some form of ordering in a result set. In the SQL world, without an ORDER BY clause, query results order is not guaranteed. What if you are working in the pandas world? Fear not. You can order DataFrame results in a similar fashion as that of ORDER BY using the sort_values() function. Let’s learn together by example…

[Head this way for great PostgresSQL and Python blogging >>>]