![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
.. image:: https://img.shields.io/pypi/v/flask_replicated.svg :target: https://pypi.python.org/pypi/flask_replicated
Flask replicated is a Flask extension, designed to work with
SqlAlchemy. It's purpose it to provide more or less automatic
master-slave replication. On each request, extension determines database
usage intention (to read or to write into a database). Then, it picks
right database url inside overriden db.get_engine()
whenever request
handler tries to access database depending on REST verb used.
Flask replicated comes with a security kill-switch to enable developper mode
to easily keep control on the feature AUTO_READ_ON_SLAVE
true by default,
once deactivated only master database will be used unless explicit use of the decorators.
Install flask replicated distribution using pip install flask_replicated
.
Or add flask-replicated==1.4
in requirements.txt and requirements
pip3 install -r requirements.txt
.
Import library from flask_replicated import FlaskReplicated
or
import flask_replicated
depending on how you want to call the functions or decorators
In flask app.config
configure your database bindings a standard way::
AUTO_READ_ON_SLAVE = True
SQLALCHEMY_DATABASE_URI = '%(schema)s://%(user)s:%(password)s@%(master_host)s/%(database)s'
SQLALCHEMY_BINDS = {
'master': SQLALCHEMY_DATABASE_URI,
'slave': '%(schema)s://%(user)s:%(password)s@%(slave_host)s/%(database)s'
}
Register app extension::
app = Flask(...)
...
FlaskReplicated(app)
Flask replicated routes SQL queries into different databases based on
request method. If method is one of READONLY_METHODS
which are defined
as set(['GET', 'HEAD']) and config AUTO_READ_ON_SLAVE
has not been set
While this is usually enough there are cases when DB access is not controlled explicitly by your business logic. Good examples are implicit creation of sessions on first access, writing some bookkeeping info, implicit registration of a user account somewhere inside the system. These things can happen at arbitrary moments of time, including during GET requests.
To handle these situations wrap appropriate view function with
@flask_replicated.use_master_database
decorator. It will mark function to
always use master database url.
Conversely, wrap the view function with the @flask_replicated.use_slave_database
decorator if you want to ensure that it always uses the slave replica.
GET after POST
There is a special case that needs addressing when working with
asynchronous replication scheme. Replicas can lag behind a master
database on receiving updates. In practice this mean that after
submitting a POST form that redirects to a page with updated data this
page may be requested from a slave replica that wasn't updated yet. And
the user will have an impression that the submit didn't work.
FAQs
Flask SqlAlchemy router for stateful master-slave replication
We found that flask-replicated demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.