Table of Contents

22.4.5 Class DatabaseUser (gb.db)

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.

22.4.5.1 Properties

The DatabaseUser class has four properties:

PropertyData typeDescription
AdministratorBooleanReturns whether a user is a database administrator or not. The property can only be read.
ConnectionConnectionReturns the parent DB connection object of the user. The property can only be read.
NameStringReturns the name of the user. The property can only be read.
PasswordStringSets the password of the specified DB user or reads it in encrypted form.

Table 22.4.5.1.1 : Properties of the DatabaseUser class

22.4.5.2 Methods

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!