Django + CUBRID (SQLAlchemy Bridge)¶
Django does not have a native CUBRID backend. This example shows how to use SQLAlchemy as a bridge while keeping Django for request handling.
Connection URL: cubrid+pycubrid://dba@localhost:33000/testdb
Minimal structure¶
templates/django/
├── manage.py
├── settings.py
├── app/
│ ├── __init__.py
│ ├── db.py
│ ├── urls.py
│ └── views.py
├── tests/
│ ├── conftest.py
│ └── test_bridge.py
├── requirements.txt
└── README.md
Install and run¶
From the repository root:
Routes (JSON only)¶
GET /healthchecks CUBRID withSELECT 1GET /itemslists rows fromcookbook_django_itemsPOST /itemscreates one row
Example create payload:
is_active is saved as integer 1 or 0.
Table creation hook¶
app/views.py uses lazy initialization with _ensure_tables_initialized() to create cookbook_django_items on first request.
Test the CUBRID bridge¶
The live test uses Django's HTTP test client for /health and /items, then
updates and deletes the saved row through this example's SQLAlchemy session.
It does not introduce or test a native Django CUBRID backend, Django ORM model,
or Django migration.
Run it against a dedicated, empty CUBRID database:
pip install -r requirements.txt pytest
export CUBRID_TEST_URL="cubrid+pycubrid://dba@localhost:33000/testdb"
python -m pytest tests -v
With no CUBRID_TEST_URL, the live test skips. An unreachable or non-CUBRID
configured URL fails. The test refuses to touch a database where
cookbook_django_items already exists, and removes only the table it created.