Provides an adapter for using the package database with PostgreSQL. The implementation relies on the package postgres.
dependencies:
database: any
database_adapter_postgre: any
import 'package:database/database.dart';
import 'package:database/sql.dart';
import 'package:database_adapter_postgre/database_adapter_postgre.dart';
Future main() async {
final config = Postgre(
host: 'localhost',
port: 5432,
user: 'your username',
password: 'your password',
databaseName: 'example',
);
final sqlClient = config.database().sqlClient;
final result = await sqlClient.query('SELECT name FROM employee').toRows();
for (var row in result.rows) {
print('Name: ${row[0]}');
}
}