User Tools

Site Tools


Sidebar

Databases

k22:k22.4:k22.4.12:start

22.4.12 Class Blob (gb.db)

Blob stands for `Binary large object` as a large binary data object that is processed by database management systems (DBMS) in a special way. The class 'Blob' cannot be created. A blob object is returned by a blob field and is used to read or write its contents.

In connection with databases and the field type `BLOB`, you will find the argument that alternative approaches also exist for storing images directly in a field of a DB table, for example:

  • Convert image to text via Base64 and save the (ASCII) text in a text field.
  • Save only the image path as a reference to the actual storage location of the BLOBs in a text field and save the corresponding image in a folder in the file system to which the DB user has read and write access.

The second approach is favored on the grounds that images and other binaries should be stored in the file system because the file system is the storage for files. In addition, the DBMSs supported by Gambas handle the field type `BLOB` in different ways. The DBMS MySQL, for example, makes no distinction between a blob field and a normal text field. One problem with the processing of BLOBs by databases is that the data in the BLOBs is unstructured from a database perspective and therefore unreadable. The database operations for BLOBs are therefore limited to complete reading, saving and reading.

Although the storage and processing of BLOBs in databases tends to be inefficient, there are also advantages associated with this. All data - including the BLOBs - is integrated and referenced in the database schema. Backups of the database in the form of dumps contain all relevant data. Another advantage is that the access rights to the data in MySQL (MariaDB) and PostgreSQL are regulated by the rights management of the database system.

Chapter 22.13 presents projects in which large binary data objects are stored directly or indirectly in a database table for different DBMS (SQLite3, PostgreSQL and MySQL).

Detailed information on large binary data objects in terms of DB data types can be found in chapter 22.3 DB mapping and under the link: http://gambaswiki.org/wiki/doc/db-type-mapping.

22.4.12.1 Properties

The Blob class only has two properties:

PropertyData typeDescription
DataStringSets the field content or returns the field content.
LengthIntegerDelivers the length of the blob content as the number of bytes.

Table 22.4.12.1.1 : Properties of the Blob class

The website uses a temporary session cookie. This technically necessary cookie is deleted when the browser is closed. You can find information on cookies in our privacy policy.
k22/k22.4/k22.4.12/start.txt · Last modified: 27.04.2024 by emma

Page Tools