SqlClient class

SQL client for accessing a Database.

import 'package:database/database.dart';
import 'package:database/sql.dart';
import 'package:database_adapter_postgre/database_adapter_postgre.dart';

Future<void> main() {
  final sqlClient = Postgre(
    // ...
  ).database().sqlClient;

  // Read rows
  final results = sqlClient.query('SELECT * FROM person').readMapStream();

  // Insert rows
  await sqlClient.table('person').insert({'name': 'Alan Turing'});

  // Delete rows
  await sqlClient.table('person').where{'NAME = ?', ['Alan Turing']).deleteAll();
}
Inheritance

Constructors

SqlClient(Database database)
Constructs a new SQL client. [...]

Properties

database Database
Database.
final
hashCode int
The hash code for this object. [...]
read-only, inherited
isClosed bool
Is the client closed?
read-only
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

Methods

close() Future
Releases resources that may be associated with this client. After closing, any attempt to communicate with the database using this client should throw StateError. [...]
createTable(String tableName) Future<void>
Creates a SQL table. [...]
inherited
dropTable(String tableName) Future<void>
Drops a SQL table. [...]
inherited
execute(String sql, [List arguments]) Future<SqlStatementResult>
Performs a SQL statement. The SQL statement should be INSERT, UPDATE, DELETE, or a schema changing statement such as CREATE. [...]
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
query(String sql, [List arguments]) SqlClientTableQueryHelper
Performs a SQL query. The SQL statement should be a SELECT statement. [...]
inherited
rawExecute(SqlStatement sqlSource) Future<SqlStatementResult>
Sends SQL statement. Unlike execute, takes SqlStatement as argument.
override
rawQuery(SqlStatement sqlSource) Future<SqlIterator>
Sends SQL query. Unlike query, takes SqlStatement as argument.
override
runInTransaction(Future<void> callback(SqlTransaction sqlTransaction), {Duration timeout}) Future<void>
Runs the function in a transaction. [...]
table(String name) SqlClientTableHelper
Returns a helper for building SQL statements. [...]
inherited
toString() String
Returns a string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator. [...]
inherited