Answer the question
In order to leave comments, you need to log in
How to organize CRUD code with FLASK/MySql/mysql.connector stack?
When writing a training project with a FLASK/MySql/mysql.connector stack, I chose the following structure:
my-wallet
├── config.ini
├── creation_shcema.sql
├── main.py
├── my_wallet
│ ├── services.py
│ └── storage.py
├── readme.md
└── requirements.txt
In the storage.py file, I placed SQL queries and functions executing them so that it looked like this:
SQL_CREATE_TRANSACTION = '''INSERT INTO transaction(user_id, description, amount) VALUES (%s, %s, %s)'''
@db_connect_decorator
def create_transaction(cursor, user_id, description, amount):
cursor.execute(SQL_CREATE_TRANSACTION, (user_id, description, amount))
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question