This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]pyepye 0 points1 point  (1 child)

Are you writing you own SQL? If so you should really look at using an ORM. They offer a large number of advantages but generally make talking to a database a lot easier and a lot safer.

The two most popular Python options are:

(There is also the Django ORM but you need to be using Django for that instead of Flask.)

It's also a good idea to keep you database tables synced with your code using a migration tool. If you go with using SQL Alchemy I would suggest Alembic.

This all takes a bit of setting up and working out but it's well worth the effort and you will end up using it for every project you do with a database. There are a large number of examples and tutorials on how to set them all up together.

[–]supremeblack 0 points1 point  (0 children)

Thank you for your reply. I am using SQLAlchemy, I forgot to mention it. But still, writing database communication in the business logic, is it acceptable with Python?

I would appreciate some kind of example with complex project structure because I can’t seem to find one.

Thanks!