{"id":37073745,"url":"https://github.com/weynelucas/django-db-adapter","last_synced_at":"2026-01-14T08:39:29.609Z","repository":{"id":53593960,"uuid":"129279481","full_name":"weynelucas/django-db-adapter","owner":"weynelucas","description":"A flexible toolkit for customize how Django creates the database objects for the application schema","archived":false,"fork":false,"pushed_at":"2024-03-20T15:49:59.000Z","size":85,"stargazers_count":7,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-08-10T00:11:19.039Z","etag":null,"topics":["application-schema","database","django","oracle","python","sql-statements"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/weynelucas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-12T16:18:33.000Z","updated_at":"2023-12-23T04:12:23.000Z","dependencies_parsed_at":"2022-09-15T07:13:49.903Z","dependency_job_id":null,"html_url":"https://github.com/weynelucas/django-db-adapter","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/weynelucas/django-db-adapter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weynelucas%2Fdjango-db-adapter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weynelucas%2Fdjango-db-adapter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weynelucas%2Fdjango-db-adapter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weynelucas%2Fdjango-db-adapter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/weynelucas","download_url":"https://codeload.github.com/weynelucas/django-db-adapter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weynelucas%2Fdjango-db-adapter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28414670,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T08:38:59.149Z","status":"ssl_error","status_checked_at":"2026-01-14T08:38:43.588Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["application-schema","database","django","oracle","python","sql-statements"],"created_at":"2026-01-14T08:39:28.988Z","updated_at":"2026-01-14T08:39:29.595Z","avatar_url":"https://github.com/weynelucas.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Django DB adapter\n\n[![Test](https://github.com/weynelucas/django-db-adapter/actions/workflows/test.yml/badge.svg)](https://github.com/weynelucas/django-db-adapter/actions/workflows/test.yml)\n[![Package](https://github.com/weynelucas/django-db-adapter/actions/workflows/deploy.yml/badge.svg)](https://github.com/weynelucas/django-db-adapter/actions/workflows/deploy.yml)\n[![codecov](https://codecov.io/gh/weynelucas/django-db-adapter/branch/master/graph/badge.svg?token=EZyTLmsPhm)](https://codecov.io/gh/weynelucas/django-db-adapter)\n[![PyPI - Release](https://img.shields.io/pypi/v/django-db-adapter.svg)](https://pypi.python.org/pypi/django-db-adapter)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/django-db-adapter)](https://pypi.python.org/pypi/django-db-adapter)\n[![PyPI - Django Version](https://img.shields.io/pypi/djversions/django-db-adapter)](https://pypi.python.org/pypi/django-db-adapter)\n[![Downloads](https://pepy.tech/badge/django-db-adapter)](https://pepy.tech/project/django-db-adapter)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\n\nA flexible toolkit for customize how Django creates the databse objects for the\napplication schema\n\n# Overview\nDjango DB adapter is a flexible schema editor backend built to solve the following problems:\n\n- Generate SQL statements for projects working on database-first approach\n- All objects created (including created from Django) must have a particular name pattern, like add prefixes and suffixes\n- All table columns should be commented\n- Inline constraints (primary/foreign keys, unique/check constraints and indexes) are not allowed\n- The database user of application is not the owner of the objects and has no privilege to create/alter/drop them (`python manage.py migrate` will not work for this user). All DDL statements generated should include a grant of manipulation privileges (select/insert/update/delete) on created objects for this user/role\n- The order of SQL statements matters\n\n\n# Requirements\n- Python (3.6, 3.7, 3.8, 3.9)\n- Django (1.11, 2.2)\n\n\nWe highly recommend and only officially support the latest patch release of each Python and Django series.\n\n# Installation\nInstall using `pip`...\n\n```bash\npip install django-db-adapter\n```\n\nAdd `'db_adapter'` to your `INSTALLED_APPS` setting.\n\n```python\nINSTALLED_APPS = [\n    ...\n    'db_adapter',\n]\n```\n\n\n# Quick Example\nLet's take a look at a quick example of using DB adapter to customize the DDL\nstatements generated by Django.\n\nThis example model defines a `Person`, which has a `first_name` and `last_name`:\n\n```python\nfrom django.db import models\n\nclass Person(models.Model):\n    first_name = models.CharField(max_length=30)\n    last_name = models.CharField(max_length=30, help_text=\"It's your last name\")\n\n    class Meta:\n        db_table = 'person'\n```\n\nAdd the following to your `settings.py` module:\n\n```python\nINSTALLED_APPS = [\n    ...  # Make sure to include the default installed apps here.\n    'db_adapter',\n]\n\nDATABASES = {\n    'default': {\n        # Make sure to include `db_adapter.db.backends.oracle` as database\n        # engine for schema customization\n        'ENGINE': 'db_adapter.db.backends.oracle',\n        'NAME': 'xe',\n        'USER': 'a_user',\n        'PASSWORD': 'a_password',\n        'HOST': 'dbprod01ned.mycompany.com',\n        'PORT': '1540',\n    }\n}\n\nDB_ADAPTER = {\n    'DEFAULT_ROLE_NAME': 'rl_example',\n    # Apply this pattern for all tables\n    'DEFAULT_DB_TABLE_PATTERN': '\"example\".\"tb_{table_name}\"',\n    # Ignore some patterns from normalization\n    'IGNORE_DB_TABLE_PATTERNS': [\n        '\"{}\".\"{}\"', # Tables with already declared namespace\n        'django_migrations', # Django migrations table\n    ],\n    'DEFAULT_OBJECT_NAME_PATTERNS': {\n        'SEQUENCE': 'sq_{table_name}',\n        'TRIGGER': 'tg_{table_name}_b',\n        'INDEX': 'ix_{name}',\n        'PRIMARY_KEY': 'cp_{name}',\n        'FOREIGN_KEY': 'ce_{name}',\n        'UNIQUE': 'ct_{name}_uq',\n        'CHECK': 'ct_{name}{qualifier}',\n    },\n    'SQL_FORMAT_OPTIONS': {\n        'unquote': True,\n        'identifier_case': 'lower',\n        'keyword_case': 'lower',\n    },\n    # Order of SQL statements\n    'SQL_STATEMENTS_ORDER': [\n        'PRIMARY_KEY',\n        'UNIQUE',\n        'FOREIGN_KEY',\n        'CHECK',\n        'INDEX',\n        'COMMENT',\n        'CONTROL', # Grant/revoke table privileges for specified role (if exists)\n        'AUTOINCREMENT', # Sequence and triggers for auto-incremented fields\n    ]\n}\n```\n\nThe above `Person` model would create a database table like this:\n\n```sql\ncreate table example.tb_person (\n    id number(11),\n    first_name nvarchar2(30),\n    last_name nvarchar2(30)\n);\n/\n\nalter table example.tb_person\n    add constraint cp_person_id\n    primary key (id);\n/\n\nalter table example.tb_person\n    add constraint ct_person_id_nn\n    check (id is not null);\n/\n\nalter table example.tb_person\n    add constraint ct_person_first_name_nn\n    check (first_name is not null);\n/\n\nalter table example.tb_person\n    add constraint ct_person_last_name_nn\n    check (last_name is not null);\n/\n\ncomment on column example.tb_person.last_name\n    is 'It''s your last name';\n/\n\ngrant select, insert, update, delete\n    on example.tb_person\n    to rl_example;\n/\n\ncreate sequence example.sq_person\n    minvalue 1\n    maxvalue 99999999999\n    start with 1\n    increment by 1\n    cache 20;\n/\n\ngrant select\n    on example.sq_person\n    to rl_example;\n/\n\ncreate or replace trigger example.tg_person_b\nbefore insert on example.tb_person\nfor each row\nwhen (new.id is null)\n    begin\n        select example.sq_person.nextval\n        into :new.id from dual;\n    end;\n/\n```\n\n# Release notes\n\n- `v1.0.0` - Apr 16, 2018 - First release\n- `v1.0.1` - Apr 16, 2018 - Rename package and fix setup issues\n- `v1.0.2` - Apr 17, 2018 - Fix documentation preview\n- `v2.0.0` - Mar 1, 2021 - Recreate the entire schema editor backend with more flexible features\n- `v2.0.1` - Mar 22, 2021 - Escape single quotes on column comments\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweynelucas%2Fdjango-db-adapter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweynelucas%2Fdjango-db-adapter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweynelucas%2Fdjango-db-adapter/lists"}