getConnection method

Future<MySQLConnection> getConnection()

Implementation

Future<MySQLConnection> getConnection() async {
  if (_connection == null) {
    _connection = await MySQLConnection.createConnection(
      host: config.getRequired<String>('database.host'),
      port: config.getRequired<int>('database.port'),
      userName: config.getRequired<String>('database.user'),
      databaseName: config.getRequired<String>('database.database'),
      password: config.getRequired<String>('database.password'),
      secure: config.getRequired<bool>('database.secure'),
      //maxConnections: 10
    );
    await _connection!.connect();
  }
  return _connection!;
}