User Tools

Site Tools


Sidebar

Databases

k22:start

22.0 Databases

Gambas supports access to various databases (DB) and database servers such as MySQL and PostgreSQL as well as the SQLite-C library. Access via ODBC also exists.

The installation and configuration of the database servers for PostgreSQL and MySQL are described in two digressions. This includes a description of working on the console with a DB client using the structured query language for databases (SQL). For your work as a programmer, this means a mediating role in the interaction between DB administrator and DB user.

Establishing a connection between DB client and DB server is part of the chapter. With the Create, Edit and Find methods, with which a DB-Result object can be created, Gambas offers everything necessary to communicate with a database and thus abstracts the differences between the individual SQL dialects. This allows you to communicate with the database regardless of the database type. The Exec method, with which you can send SQL statements directly to the database server, is also described.

Accessing a database and the DB tables is easy because Gambas provides a series of controls for a DB client, which you arrange in a form. You will find the database controls in the 'Data' section of the toolbox. With the DataBrowser - within the DataSoures control - you can browse within a database table. The element also allows you to add and delete data records. For this purpose, it provides a toolbar with buttons for navigating in the data records, creating and deleting as well as saving data records. The DataView element displays selected DB data in tabular form, while DataControl provides an element for reading and writing the content of a field in a table:

PICTURE

Figure 22.0.1: Database controls

Databases are generally intended for data storage in multi-user environments and for mass data. You must always test whether you can write high-performance applications for mass data with the bound DB controls.

The topic of 'data modelling' in connection with normalisation is only dealt with as an example in the DB projects presented; the same applies to 'referential integrity'. Concepts for database design are not covered in this chapter.

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/start.txt · Last modified: 27.04.2024 by emma

Page Tools