earn the White PyBites Ninja earn the Yellow PyBites Ninja earn the Orange PyBites Ninja right arrow earn more PyBites Ninja belts and certificates
The best way to learn to code in Python is to actually use the language.

Our platform offers effective Test Driven Learning which will be key to your progress.

Join thousands of Pythonistas and start coding!

Join us on our PyBites Platform
Click here to code!

Code Challenge 51 - Analyse NBA Data with SQL/sqlite3 - Review

Posted by PyBites on Mon 24 September 2018 in Challenges • 1 min read

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.executemany to bulk insert records.

  • We were using cursor.fetchall but to get one record/row you can use fetchone (thanks @clamytoe)

  • Practice GROUP BY (year_with_most_drafts)

  • 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!)

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

See an error in this post? Please submit a pull request on Github.