This class represents a user of a database for PostgreSQL and MySQL.
Attention:
SQLite has no user concept. Access to an SQLite database is controlled by the actual file permissions of the database file. This means that the login is always the user ID that executes the Gambas programme.
The DatabaseUser class has four properties:
Property | Data type | Description |
---|---|---|
Administrator | Boolean | Returns whether a user is a database administrator or not. The property can only be read. |
Connection | Connection | Returns the parent DB connection object of the user. The property can only be read. |
Name | String | Returns the name of the user. The property can only be read. |
Password | String | Sets the password of the specified DB user or reads it in encrypted form. |
Table 22.4.5.1.1 : Properties of the DatabaseUser class
The DatabaseUser class only has the Sub Delete ( ) method. It deletes the specified DB user.
Example
You can use the following source code to read information about the users of PostgreSQL and MySQL databases:
Dim hDataBase As Database Dim hDBUser As DatabaseUser For Each hDataBase In DBCS.DBConnection.Databases If DBCS.DBConnection.Type Begins "sqlite" Then Print "The database `"; hDataBase.Name; "` is an SQLite database." Print "The information on the DB user (DBUserName, DBUserPassword) therefore does not exist!" Else Print "If the DBUser is a DBAdministrator: "; IIf(hDBUser.Administrator = True, "yes", "no") Print "DBUser: "; hDBUser.Name Print "DBConnection: "; hDBUser.Connection Print "DBPassword: "; IIf(hDBUser.Password, "hDBUser.Password", "Do not set a password.") Print "................................" Endif Next
This is the output in the console of the Gambas IDE for a database connection to exactly one SQLite3 database:
The database `contacts.sqlite` is an SQLite database. The DB user details (DBUserName, DBUserPassword) therefore do not exist!