In this article we review last week's Analyse NBA Data with SQL/sqlite3 code challenge.
Check out our solution for this challenge.
cursor.executemany to bulk insert records.
We were using
cursor.fetchall but to get one record/row you can use
fetchone (thanks @clamytoe)
GROUP BY (
Simple SQLite arithmetic (
games/active AS games_per_year)
Probably don't need
CAST if you add types to DB columns (looking at other PRs!)
Check out solutions PR'd by our community.
Some learnings taken from these Pull Requests:
Refreshed SQL. Learned about sqlite command line. Learned PyCharm DataSource integration and querying. Refreshed git commands.
I used this challenge as a chance to experiment with Jupyter notebook to help visualize the data
Other learnings we spotted in Pull Requests week: itertools, difflib / similarity measures, collections, pytest and patch.
Thanks to everyone for your participation in our blog code challenges!
Subscribe to our blog (sidebar) to get a new PyBites Code Challenge (PCC) in your inbox each Monday.
And/or take any of our 50+ challenges on our platform.
Prefer coding self contained exercises in the comfort of your browser? Try our growing collection of Bites of Py.
Keep Calm and Code in Python!
-- Bob and Julian
Do you want to get 250+ concise and applicable Python tips in an ebook that will cost you less than 10 bucks (future updates included), check it out here.
"The discussions are succinct yet thorough enough to give you a solid grasp of the particular problem. I just wish I would have had this book when I started learning Python." - Daniel H
"Bob and Julian are the masters at aggregating these small snippets of code that can really make certain aspects of coding easier." - Jesse B
"This is now my favourite first Python go-to reference." - Anthony L
"Do you ever go on one of those cooking websites for a recipe and have to scroll for what feels like an eternity to get to the ingredients and the 4 steps the recipe actually takes? This is the opposite of that." - Sergio S