# Introducing django-db-tools

DevFeed: [Introducing django-db-tools](<https://devfeed.tech/articles/introducing-django-db-tools-41125.md>)

Original publisher: [Read original article](<https://www.craigkerstiens.com/2013/02/08/Introducing-django-db-tools/>)

Author: Map

Published: 2013-02-08T20:55:56Z

Content type: release

Language: en

Sources: [Craig Kerstiens](<https://devfeed.tech/sources/craig-kerstiens.md>)

Topics: [migration](<https://devfeed.tech/topics/migration.md>), [Django](<https://devfeed.tech/topics/django.md>), [middleware](<https://devfeed.tech/topics/middleware.md>), [MySQL](<https://devfeed.tech/topics/mysql.md>), [Databases](<https://devfeed.tech/topics/databases.md>), [web applications](<https://devfeed.tech/topics/web-applications.md>)

Tags: [database](<https://devfeed.tech/tags/database.md>), [django](<https://devfeed.tech/tags/django.md>), [downtime](<https://devfeed.tech/tags/downtime.md>), [github](<https://devfeed.tech/tags/github.md>), [heroku](<https://devfeed.tech/tags/heroku.md>), [http](<https://devfeed.tech/tags/http.md>), [middleware](<https://devfeed.tech/tags/middleware.md>), [migration](<https://devfeed.tech/tags/migration.md>), [mysql](<https://devfeed.tech/tags/mysql.md>), [python](<https://devfeed.tech/tags/python.md>)

## AI overview

This article announces django-db-tools, a lightweight Django middleware utility for operating a web application in limited read-only modes during large database migrations. It provides an anonymous mode and a mode that treats POST requests as GET requests to help prevent data insertion, with configuration through environment variables or Heroku config variables.

## Source excerpt

For any successful web application there is likely to come a time when you need to conduct some large migration on the backend. I dont mean simple add a column here or add an index there, but rather truly sizeable migrations... Going from MySQL to Postgres or migrating from an older version of Postgres such as a 32 bit instance to a newer 64 bit instance. In these cases the default approach is to just schedule downtime often throwing up a splash screen saying so. For many sites this approach is simply wrong and lazy, with little effort you can improve the experience and there by ease the burden in conducting these types of migrations. By having the ability to turn your site into a read only mode which Simon Wilson talked about in his post on Lanyrd you can still continue to operate just in a limited capacity. Andrew Godwin further talks about some of this as well in regards to the Lanyrd move and even includes the script they used to migrate data from MySQL to Postgres. Though just in talking with Simon about this a week ago it occurred to me they had not released the code for their read-only mode. Finally onto the announcing, today I'm releasing django-db-tools. This is currently a very lightweight utility that allows you to flip your site into two modes. Anonymous Mode For sites that offer a bulk of their data to unauthenticated users anonymous mode will be what you want. This ensures all users appear logged out and thus cannot interact with data. To enable anonymous mode you'd simple set the environment variable or config var on heroku as follows: READ_ONLY_MODE = True Restricting POSTs The other bucket of sites is one that allows users to stay logged in but not insert data. Django did not appear to have a convenient means to know whether data was actually being inserted into the DB or not. As a good practice when inserting data it should be receiving a HTTP POST. The GET_ONLY_MODE mimmicks all POSTs as if they were sent via GETs thus hopefully eliminating insertin