In order to config the database connection, the following ENV variables needs to be set up:
DB_HOST
DB_PORT
DB_NAME
DB_USER
DB_PASSWORD
Install requirements from requirements.txt
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser --email [email protected] --username admin
GET: http://127.0.0.1:8000/api/table/
Response returns a list of all dynamic models currently available.
[
{
"pk": 1,
"name": "table_1"
},
{
"pk": 2,
"name": "table_2"
}
]
POST: http://127.0.0.1:8000/api/table/
Request must contain the model that we want to create.
{
"name": "table_3",
"columns": [{
"name": "first_column",
"type": "INTEGER"
},
{
"name": "second_column",
"type": "STRING"
}]
}
Response returns the model that was created or an error if it occurs.
{
"name": "table_3",
"columns": [{
"name": "first_column",
"type": "INTEGER"
},
{
"name": "second_column",
"type": "STRING"
}]
}
PUT: http://127.0.0.1:8000/api/table/<primary_key>/
Request must contain the new model definition.
{
"name": "table_3_renamed",
"columns": [{
"name": "first_column",
"type": "INTEGER"
},
{
"name": "second_column",
"type": "STRING"
},
{
"name": "third_column",
"type": "STRING"
}]
}
Response returns the new model definition or an error it updates failed.
{
"name": "table_3_renamed",
"columns": [{
"name": "first_column",
"type": "INTEGER"
},
{
"name": "second_column",
"type": "STRING"
},
{
"name": "third_column",
"type": "STRING"
}]
}
DELETE: http://127.0.0.1:8000/api/table/<primary_key>/
Response returns 200 OK if the model was deleted or an error if delete fails.
GET: http://127.0.0.1:8000/api/table/<primary_key>/rows
Response return a list of all rows currently stored for the model.
[
{
"first_column": 1,
"second_column": "test123",
"third_column": null
},
{
"first_column": 1,
"second_column": "test123",
"third_column": "this works!"
}
]
GET: http://127.0.0.1:8000/api/table/<primary_key>/row/
Request must contain valid data for selected model.
{
"first_column": 1,
"second_column": "test123",
"third_column": "this works!"
}
Response returns the created row, or an error if insert fails.
{
"pk": 2,
"first_column": 1,
"second_column": "test123",
"third_column": "this works!"
}