I've been developing a small shop manager application for Windows using Python and PyQt6 for the user interface, while SQLite3 serves as the database. I'm at a point where I need to decide if SQLite3 is a good choice for the production version of my application. One of my main concerns is managing database schema changes—for instance, I'm regularly adding new columns, removing old ones, and making adjustments to table structures. I'm really worried about the potential for losing existing data, such as past transactions, products, and suppliers during these updates. What strategies can I use to update my database schema without risking data loss? Should I stick with SQLite and implement migrations, or would it be wiser to switch to a different database like PostgreSQL or MySQL for this application? I'd love to hear your thoughts and any best practices you have!
5 Answers
If your application is running on a single machine, SQLite3 should work just fine. People have been using it effectively for web apps, so it can handle your needs. To avoid losing data, I recommend using Litestream to back up your database regularly. Also, be sure to make a backup of your database files before running any migrations. I've used SQLite3 in production and have managed migrations without data loss, so you should be good as long as you keep it all local!
I think your main concern should be about supporting multiple users. If your shop manager is going to have several people accessing and updating data, SQLite might not be the best fit since it's designed for single-user scenarios. Always be cautious when working on live systems; having a backup environment for testing updates is essential. Mistakes happen, so a good backup routine is crucial to prevent any data loss.
You're right to be cautious about schema changes in any SQL database. Just because SQLite is lighter doesn't mean it won't face similar issues as PostgreSQL or MySQL. I think those databases might offer additional features, but the core challenges around schema changes are pretty much the same across the board.
SQLite can handle schema changes pretty smoothly, just like MySQL and PostgreSQL. While the `ALTER TABLE` statement in SQLite is a bit more limited, it still allows you to make necessary modifications. For more complex changes, create a new table, copy the data over while transforming it as needed, and delete the old table. Be sure to do everything in a transaction to keep your data safe in case anything goes wrong!
SQLite is a reliable choice, especially for local use, but ensure you back it up properly, as it doesn’t have the recovery mechanisms found in distributed systems. When dealing with schema changes, you may encounter similar processes as other databases. Just make sure your migrations are well-planned and avoid unnecessary deletions, which is where most data loss occurs. Just stick to making careful updates!

Yeah, I’m new to programming, so I just figured that bigger databases like MySQL and PostgreSQL might have some more tools to handle these changes better. SQLite definitely has its perks, though!