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
#2
(Feb-03-2023, 11:46 AM)MorganSamage Wrote: However, celery requires a worker server, such as RabbitMQ, and after speaking to the hosting company, they say this is not allowed.
It could be Redis as well if available from hosting
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
(Feb-03-2023, 11:56 AM)buran Wrote:
(Feb-03-2023, 11:46 AM)MorganSamage Wrote: However, celery requires a worker server, such as RabbitMQ, and after speaking to the hosting company, they say this is not allowed.
It could be Redis as well if available from hosting

Hi, and thanks for the quick response.

I did think of Redis, but the hosting company were implying that this type of functionality is not allowed, and I did send them the info on RabbitMQ and Redis, but just to make sure, I will ask them the direct question, regarding Redis.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Flask_table module compatibility issue: cannot import name 'Markup' from 'flask' venkateshbalagiri 1 419 Mar-22-2024, 05:07 AM
Last Post: venkateshbalagiri
Shocked FLASK confuse LennyKiz 1 539 Nov-05-2023, 04:23 PM
Last Post: Axel_Erfurt
  Flask - use bootstrap styles in HTML Krayna 1 1,069 Aug-29-2023, 02:33 PM
Last Post: menator01
  Flask CORS not functioning michaelnicol 1 1,388 Jul-02-2023, 05:04 PM
Last Post: michaelnicol
  Flask & Files Gilush 1 1,704 Apr-07-2023, 08:23 AM
Last Post: SpongeB0B
  Flask: sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) database is locked pythonpaul32 1 2,134 Apr-04-2023, 07:44 AM
Last Post: Larz60+
  Flask error sqlalchemy.exc.IntegrityError: (sqlite3.IntegrityError) UNIQUE constraint pythonpaul32 2 3,713 Feb-21-2023, 03:13 AM
Last Post: noisefloor
  flask.cli.NoAppException: Could not import 'app' kazu755 4 4,828 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,746 Feb-07-2023, 10:48 AM
Last Post: pythonpaul32
  REST API using flask - limit connection? korenron 1 1,272 Feb-05-2023, 06:48 PM
Last Post: noisefloor

Forum Jump:

User Panel Messages

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