mysql1 0.16.2 copy "mysql1: ^0.16.2" to clipboard
mysql1: ^0.16.2 copied to clipboard

outdated

MySQL driver for Dart

example/example.dart

import 'dart:async';

import 'package:mysql1/mysql1.dart';

Future main() async {
  // Open a connection (testdb should already exist)
  final conn = await MySqlConnection.connect(new ConnectionSettings(
      host: 'localhost', port: 3306, user: 'root', db: 'testdb'));

  // Create a table
  await conn.query(
      'CREATE TABLE users (id int NOT NULL AUTO_INCREMENT PRIMARY KEY, name varchar(255), email varchar(255), age int)');

  // Insert some data
  var result = await conn.query(
      'insert into users (name, email, age) values (?, ?, ?)',
      ['Bob', 'bob@bob.com', 25]);
  print("Inserted row id=${result.insertId}");

  // Query the database using a parameterized query
  var results = await conn
      .query('select name, email from users where id = ?', [result.insertId]);
  for (var row in results) {
    print('Name: ${row[0]}, email: ${row[1]}');
  }

  // Finally, close the connection
  await conn.close();
}
469
likes
0
pub points
97%
popularity

Publisher

unverified uploader

MySQL driver for Dart

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

collection, crypto, logging, pool

More

Packages that depend on mysql1