mysql1_ext

Last updated:

0 purchases

mysql1_ext Image
mysql1_ext Images
Add to Cart

Description:

mysql1 ext

mysql1_ext #
A MySQL driver for the Dart programming language. Works on Flutter and on the server.
This library aims to provide an easy to use interface to MySQL. mysql1_ext originated
as a fork of the mysql1_dart.
Usage #
Connect to the database
var settings = new ConnectionSettings(
host: 'localhost',
port: 3306,
user: 'bob',
password: 'wibble',
db: 'mydb'
);
var conn = await MySqlConnection.connect(settings);
copied to clipboard
Execute a query with parameters:
var userId = 1;
var results = await conn.query('select name, email from users where id = ?', [userId]);
copied to clipboard
Use the results:
for (var row in results) {
print('Name: ${row[0]}, email: ${row[1]}');
});
copied to clipboard
Insert some data
var result = await conn.query('insert into users (name, email, age) values (?, ?, ?)', ['Bob', '[email protected]', 25]);
copied to clipboard
An insert query's results will be empty, but will have an id if there was an auto-increment column in the table:
print("New user's id: ${result.insertId}");
copied to clipboard
Execute a query with multiple sets of parameters:
var results = await query.queryMulti(
'insert into users (name, email, age) values (?, ?, ?)',
[['Bob', '[email protected]', 25],
['Bill', '[email protected]', 26],
['Joe', '[email protected]', 37]]);
copied to clipboard
Update some data:
await conn.query(
'update users set age=? where name=?',
[26, 'Bob']);
copied to clipboard
New Features: #

Add new function for CRUD operations with parameterize, this function will escape strings to reduce request binding to MySQL database.

await conn.execute('SELECT * FROM sessions WHERE session_id=:sid LIMIT 1', {'sid':'THIS IS SAMPLE SESSION'});
copied to clipboard

Add Connection Pool

var settings = new ConnectionSettings(
host: 'localhost',
port: 3306,
user: 'bob',
password: 'wibble',
db: 'mydb'
);
var conn = await MySqlConnectionPool.connect(settings);
copied to clipboard

Add asMap(Function) on Results

Flutter Web #
This package opens a socket to the database. The web platform does not support sockets and so this package does not work on flutter web.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.