In this article we review last week's Analyse NBA Data with SQL/sqlite3 code challenge.
Our solution
Check out our solution for this challenge.
Some learnings:
Use
cursor.executemanyto bulk insert records.We were using
cursor.fetchallbut to get one record/row you can usefetchone(thanks @clamytoe)Practice
GROUP BY(year_with_most_drafts)Simple SQLite arithmetic (
games/active AS games_per_year)Probably don't need
CASTif you add types to DB columns (looking at other PRs!)
Community solutions
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
Read Code for Fun and Profit
You can look at all submitted code here and/or pulling our Community branch.
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!
Need more Python Practice?
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.
Want to do the #100DaysOfCode but not sure what to work on? Take our course and/or start logging your progress on our platform.
Keep Calm and Code in Python!
-- Bob and Julian