Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Flask/non-flask database sharing
#1
Firstly, I have very little experience with python, so any constructive feedback on what I have done/should do with regards to the following issue that I have currently have, would be much appreciated.

I started creating a flask app that utilized both flask_sqlalchemy and flask_marshmallow. I got the code working and uploaded it to my shared hosting provider. All the rest api's are working as expected.

I now need to implement logic for processing large amounts of data in the database. After researching on-line, my plan was to use celery, and call a rest api that would then offload the job to celery so as not to block the rest api and cause a timeout. However, celery requires a worker server, such as RabbitMQ, and after speaking to the hosting company, they say this is not allowed.

I thought of creating another (non-flask) app that I can invoke from a cron job to do the heavy processing for me, which is allowed. The problem is that I don't want to duplicate the sqlalchemy database code that I already have, so my thought is to remove the dependency on flask for the sqlalchemy and marshmallow code and to turn all the database logic into a library that can be shared across both projects. This way, I would only have to write the database logic once.

So...
1) Am I heading down the right track?
2) Is there a better way to do this?
3) Should I just duplicate the database logic, so I can utilize the flask_sqlalchemy/flask_marshmallow packages in the flask app?
Reply


Messages In This Thread
Flask/non-flask database sharing - by MorganSamage - Feb-03-2023, 11:46 AM
RE: Flask/non-flask database sharing - by buran - Feb-03-2023, 11:56 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Flask role-based authorization erdemath 13 521 May-04-2024, 07:26 PM
Last Post: erdemath
  Flask_table module compatibility issue: cannot import name 'Markup' from 'flask' venkateshbalagiri 1 512 Mar-22-2024, 05:07 AM
Last Post: venkateshbalagiri
Shocked FLASK confuse LennyKiz 1 558 Nov-05-2023, 04:23 PM
Last Post: Axel_Erfurt
  Flask - use bootstrap styles in HTML Krayna 1 1,094 Aug-29-2023, 02:33 PM
Last Post: menator01
  Flask CORS not functioning michaelnicol 1 1,435 Jul-02-2023, 05:04 PM
Last Post: michaelnicol
  Flask & Files Gilush 1 1,719 Apr-07-2023, 08:23 AM
Last Post: SpongeB0B
  Flask: sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) database is locked pythonpaul32 1 2,181 Apr-04-2023, 07:44 AM
Last Post: Larz60+
  Flask error sqlalchemy.exc.IntegrityError: (sqlite3.IntegrityError) UNIQUE constraint pythonpaul32 2 3,817 Feb-21-2023, 03:13 AM
Last Post: noisefloor
  flask.cli.NoAppException: Could not import 'app' kazu755 4 4,924 Feb-19-2023, 01:50 PM
Last Post: Larz60+
  Flask and SQLAlchemy question: Database is being created but tables aren't adding pythonpaul32 3 4,892 Feb-07-2023, 10:48 AM
Last Post: pythonpaul32

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020