Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/runekaagaard/django-fakeit
A management command that anonymizes the database. Fast.
https://github.com/runekaagaard/django-fakeit
Last synced: 11 days ago
JSON representation
A management command that anonymizes the database. Fast.
- Host: GitHub
- URL: https://github.com/runekaagaard/django-fakeit
- Owner: runekaagaard
- License: bsd-3-clause
- Created: 2013-07-10T09:54:36.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-07-17T13:17:49.000Z (over 11 years ago)
- Last Synced: 2024-11-07T11:48:20.032Z (2 months ago)
- Language: Python
- Size: 109 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
django-fakeit
=============A management command that anonymizes the database. Fast. Only works for MySql.
Installation
============Put the following in your requirements.txt file::
git+git://github.com/runekaagaard/django-fakeit.git#egg=django-fakeit
And this in your ``settings.py`` file::FAKEIT_ALLOW = True
A good tip would be to use a ``settings_local.py`` file, to avoid nuking your
live database.Usage
=====A ``fakeit_settings.py`` must exist on the python path, and should contain::
SETTINGS = {
# These table will be emptied.
'truncate': ['auth_message', 'django_admin_log', 'django_session', ],
# These tables will be altered.
'alter': [
{
# Tablename in the database of the table to alter.
'table': 'persons_person',
# These fields will be anonymized.
'fields': {
# The callable CALLBACK1 should return a quoted name
# surrounded with ``""``.
'name': CALLBACK1,
# The callable CALLBACK2 should return a number as a string.
'number': CALLBACK2,
},
},
... MORE TABLES GO HERE.
# Which db engine to use.
'db_engine': 'django.db.backends.mysql',
}
Callbacks
=========The callbacks are responsible for creating the anonymized data. The return of
them are inserted directly into the SET command, so for string types should have
``""`` and be quoted.A full example of fakeit_settings.py using the faker module could look like::
from faker import Faker
from random import randint
FAKER = Faker()
def name():
return '"' + FAKER.name() + '"'
def phone():
return str(randint(10000000, 99999999))
SETTINGS = {
'truncate': ['auth_message', 'django_admin_log', 'django_session', ],
'alter': [
{
'table': 'persons_person',
'fields': {
'name': name,
'number': phone,
},
},
'db_engine': 'django.db.backends.mysql',
}