S
S
SergeyPostnikov2022-01-20 14:20:11
MySQL
SergeyPostnikov, 2022-01-20 14:20:11

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


And at the moment I don’t like the way the intermediate result looks at all.
Can you please tell me how to improve the code with the current stack?
Link to the project https://github.com/SergeyPostnikov/MyWallet.git

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question