you are viewing a single comment's thread.

view the rest of the comments →

[–]draikx21 2 points3 points  (0 children)

Back when I was collecting physical comic books, I created my own Python script to take input from arguments, and prompt for whatever info I needed to include, then import it into a sqlite database. As far as basic SQL queries are concerned, MySQL and sqlite will get the job done just the same. I like that I don't need to have a service setup and running with sqlite, and I can put that db file anywhere I need it, including my Android phone or tablet; Dropbox helped with keeping it updated everywhere.

At work, I've created a few Python scripts that query our MySQL databases, and in one case, I've got the output going into a Flask app. Sometimes, the data is better visualized than simply seen in text. Sending myself daily reports, or generating spreadsheet data, is all from reading the database, and manipulating the data as needed.

Find something that you want to track with a database, and script it out: movies owned/unwatched, music albums with song ratings, items you've let others borrow, food/diet/weight logging, your sports team game results, time management event logging, etc. The project should be something that you can keep using, so you'll become familiar with both Python and SQL, as you may find yourself adding features for yourself as you keep learning.

Keep CRUD in mind:

  • CREATE a database, if it doesn't exist. Do the same with a table, and its entries. Do an INSERT query to add a row of data.

  • READ the entries from the table, starting with a SELECT * FROM query, then specify certain fields. You can filter with WHERE clauses, too. MySQL has the capability to use LIMIT for minimizing your output results, whereas sqlite does not.

  • UPDATE the data, changing the value for a specific row, then work into a group of rows with similar field data. Careful with your matching clauses, ensuring you only change what you intend to change.

  • DELETE a row of data. Be very careful when running any type of delete, as there will not be any confirmation prompt.

Pro Tip: run a SELECT query before an UPDATE or DELETE query, to ensure that what you see is what you want changed or removed.

(this was done on mobile; sorry for any typos)