drift/extras/drift_mariadb/example/test.dart

38 lines
907 B
Dart
Raw Normal View History

2023-07-24 12:05:58 -07:00
import 'package:drift/backends.dart';
import 'package:drift/src/runtime/query_builder/query_builder.dart';
import 'package:drift_mariadb/drift_mariadb.dart';
import 'package:mysql_client/mysql_client.dart';
void main() async {
final mariadb = MariaDBDatabase(
2023-07-24 12:44:43 -07:00
pool: MySQLConnectionPool(
host: 'localhost',
2023-07-24 12:05:58 -07:00
port: 3306,
userName: 'root',
2023-07-24 12:44:43 -07:00
password: 'password',
databaseName: 'database',
maxConnections: 1,
secure: false,
2023-07-24 12:05:58 -07:00
),
logStatements: true,
);
await mariadb.ensureOpen(_NullUser());
final rows = await mariadb.runSelect(r'SELECT (?)', [true]);
final row = rows.single;
print(row);
print(row.values.map((e) => e.runtimeType).toList());
}
class _NullUser extends QueryExecutorUser {
@override
Future<void> beforeOpen(
QueryExecutor executor,
OpeningDetails details,
) async {}
@override
int get schemaVersion => 1;
}