exec method

Future exec(
  1. String query, [
  2. Map<String, dynamic>? args,
  3. bool? iterable = false
])

Executes a SQL query on the connected database.

This method supports both MySQL and PostgreSQL databases. For MySQL, the iterable parameter can be set to true to return an iterable result set.

  • Parameters:

    • query: The SQL query to be executed.
    • args: Optional map of query parameters to be used in the query.
    • iterable: Optional boolean indicating whether the result set should be iterable (only applicable for MySQL).
  • Returns: A future that resolves to the result of the query. The type of the result depends on the database being used: IResultSet for MySQL and Result for PostgreSQL.

Implementation

Future<dynamic> exec(
  String query, [
  Map<String, dynamic>? args,
  bool? iterable = false,
]) async {
  if (type.asString == "mysql") {
    return await conn!.execute('SELECT * FROM users', args, iterable!);
  } else if (type.asString == "postgres") {
    return await conn2!.execute(query, parameters: args);
  }
}