Dbbase

Latest version: v0.3.10

Safety actively analyzes 710445 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 4 of 5

0.2.0

Added
* Added `db.doc_table()` and `db.doc_tables()` function to help build documentation for table
objects in a way that is reminiscent of Swagger / OpenApi.

For example, here is the output in JSON format using the approach that
OpenApi takes. In fact, there are some differences. These differences
stem from the more nuanced approach that SQLAlchemy takes for things like
defaults. For example, server side defaults are specified. Also, on update functions are detailed as well.

Usage:

python
doc_table(
cls, the class
to_camel_case=False, convert column names to camel case
serial_list=None, select only specific columns
column_props=None select only certain column properties
)

Some uses for this function:
* Detail on the tables can be part of a larger communication with
developers using an API.
* Meta information can be resourced about particular views.
* Unit / integration tests can use the output to ensure that table
columns are created to specifications.

Here is an example of some of the column types that are tested.

json

{
"SampleTable": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int32",
"primary_key": true,
"nullable": true,
"comment": "Primary key with a value assigned by the database",
"info": {
"extra": "info here"
}
},
"name1": {
"type": "string",
"maxLength": 50,
"nullable": false,
"comment": "This field is required",
"info": {}
},
"indexValue": {
"type": "integer",
"format": "int32",
"nullable": true,
"server_default": {
"for_update": false,
"arg": "db.text(\"0\")",
"reflected": false
},
"comment": "This field defaults to an integer on the server.",
"info": {}
},
"createdAt1": {
"type": "date-time",
"nullable": true,
"default": {
"for_update": false,
"arg": "datetime.now"
},
"comment": "This field defaults to now, created at model level",
"info": {}
},
"updateTime1": {
"name": "update_time1",
"type": "date-time",
"nullable": true,
"onupdate": {
"for_update": true,
"arg": "datetime.now"
},
"comment": "This field defaults only on updates",
"info": {}
},
"uniqueCol": {
"type": "string",
"maxLength": 20,
"nullable": true,
"unique": true,
"comment": "This must be a unique value in the database.",
"info": {}
},
"name2": {
"type": "string",
"maxLength": 50,
"nullable": true,
"comment": "This field is not required",
"info": {}
},
"fkId": {
"type": "integer",
"format": "int32",
"nullable": false,
"foreign_key": "other_table.id",
"comment": "This field is constrained by a foreign key on another table",
"info": {}
},
"someSmallInt": {
"type": "integer",
"format": "int8",
"nullable": false,
"default": {
"for_update": false,
"arg": 0
},
"comment": "This field is a small integer",
"info": {}
},
"someInt": {
"type": "integer",
"format": "int32",
"nullable": false,
"default": {
"for_update": false,
"arg": 0
},
"comment": "This field is a 32 bit integer",
"info": {}
},
"today": {
"type": "date",
"nullable": true,
"default": {
"for_update": false,
"arg": "date.today"
},
"doc": "this is a test",
"comment": "This field defaults to today, created at model level",
"info": {
"test": "this is"
}
},
"someBigInt": {
"name": "some_big_int",
"type": "integer",
"format": "int64",
"nullable": false,
"default": {
"for_update": false,
"arg": 0
},
"comment": "This field is a big integer",
"info": {}
},
"statusId": {
"type": "integer",
"format": "int32",
"choices": {
"0": "New",
"1": "Active",
"2": "Suspended",
"3": "Inactive"
},
"nullable": false,
"comment": "Choices from a list. String descriptors change to integer upon saving. Enums without the headache.",
"info": {}
},
"name3": {
"type": "text",
"nullable": false,
"default": {
"for_update": false,
"arg": "test"
},
"index": true,
"comment": "This field has a default value",
"info": {}
},
"itemLength": {
"type": "float",
"nullable": false,
"comment": "This field is a float value",
"info": {}
},
"abc": {
"type": "string",
"maxLength": 20,
"nullable": true,
"server_default": {
"for_update": false,
"arg": "abc",
"reflected": false
},
"comment": "This field defaults to text but on the server.",
"info": {}
},
"itemAmount": {
"name": "item_amount",
"type": "numeric(17, 6)",
"nullable": true,
"default": {
"for_update": false,
"arg": 0.0
},
"info": {}
},
"updateTime2": {
"type": "date-time",
"nullable": true,
"server_onupdate": {
"for_update": true,
"arg": "db.func.now()",
"reflected": false
},
"comment": "This field defaults only on updates, but on the server",
"info": {}
},
"createdAt2": {
"type": "date-time",
"nullable": true,
"server_default": {
"for_update": false,
"arg": "db.func.now()",
"reflected": false
},
"comment": "This field defaults to now, created at the server level",
"info": {}
}
},
"xml": "SampleTable"
}
}

0.1.15

Changed
* Changed conversion of UUIDs conversion to strings to remove hyphens.
A serialized uuid is shortened from `1f4fdf7e-6f8d-4a7e-b0bd-7ae0722b324d`
to `1f4fdf7e6f8d4a7eb0bd7ae0722b324d`.

0.1.14

Added
* Added a function `validate_record` to the Model class. The
initial version evaluates a record by comparing columns defined as required
that do not have default values filled in. Of course more issues can
contribute to a failure to save a record, but it is a start. It also
has the ability to return the error message in camel case for front end
use.
The expected usage:

python
status, errors = self.validate_record()
if status:
self.save()
else:
return errors

* Added a `delete` function to the Model class.

python

dbbase
user = User(name='Bob')
User.save()

then delete
user.delete()

0.1.13

Added
* Added conversion from bytes as well as strings for the
deserialization function. This aids in conversion for
query_strings received, eliminating a step.

0.1.12

Removed
* Removed tests again. Included more thorough approach.

0.1.11

Removed
* Removed tests, docs, docsrc from setup.py

Page 4 of 5

© 2025 Safety CLI Cybersecurity Inc. All Rights Reserved.