पैकेज, रिपॉज़िटरी और ऐप श्रेणियाँ खोजें

पैकेज विवरणv2.1.14

mysql_utils

[mysql_client_plus] सहायता पुस्तकालय है, जो MySQL का उपयोग करना आसान और सरल बनाता है।

AndroidiOSmacOSWindowsLinux
30-दिन डाउनलोड
279
लाइक
62
Pub अंक
160

पैकेज इंस्टॉल करें

flutter pub add mysql_utils

पैकेज अवलोकन

सार्वजनिक जानकारी से बना चयन मार्गदर्शन। केवल संदर्भ हेतु।

mysql_utils mysql_client_plus के लिए एक सहायक पुस्तकालय है जो Flutter अनुप्रयोगों में MySQL डेटाबेस इंटरैक्शन को सरल बनाता है। यह MySQL डेटाबेस से जुड़ने, प्रश्नों को निष्पादित करने और परिणामों को हैंडल करने के लिए सुविधाजनक विधियाँ प्रदान करता है, न्यूनतम बॉइलरप्लेट के साथ। डेवलपर उत्पादकता को बढ़ाने के लिए डिज़ाइन किया गया है, यह सामान्य ऑपरेशन को अब्स्ट्रैक्ट करता है जबकि कई प्लेटफॉर्मों जैसे Android, iOS, macOS, Windows और Linux में संगतता बनाए रखता है। इस पैकेज का उपयोग जटिल सेटअप के बिना विश्वसनीय और सरल MySQL एकीकरण की आवश्यकता वाले परियोजनाओं के लिए आदर्श है।

उपयोग

  • सरल MySQL क्वेरी एक्जीक्यूशन
  • डेटाबेस कनेक्शन प्रबंधन
  • प्लेटफॉर्म-स्वतंत्र डेटाबेस पहुँच
  • सरलीकृत CRUD संचालन
  • mysql_client_plus के साथ एकीकरण

मुख्य विशेषताएँ

  • उपयोग में आसान प्रश्न इंटरफ़ेस
  • mysql_client_plus पर निर्मित
  • सभी प्रमुख डेस्कटॉप और मोबाइल प्लेटफॉर्म को समर्थन करता है
  • बॉलरप्लेट कोड को कम करता है
  • स्वचालित परिणाम विश्लेषण

इनके लिए उपयुक्त

  • MySQL कनेक्टिविटी की आवश्यकता वाले Flutter ऐप्स
  • सरल डेटाबेस सहायता चाहने वाले विकासकर्ता
  • mysql_client_plus का उपयोग करने वाले प्रोजेक्ट
  • MySQL डेटाबेस के साथ बैकएंड सेवाएँ
  • डेटाबेस के साथ त्वरित प्रोटोटाइपिंग

विचार योग्य बातें

  • mysql_client_plus के रूप में निर्भरता की आवश्यकता है
  • MySQL डेटाबेस पर सीमित
  • जटिल SQL लेनदेन के लिए उपयुक्त नहीं
  • कोई निर्मित मार्गदर्शन समर्थन नहीं है
  • बाहरी MySQL सर्वर उपलब्धता पर निर्भर

मूल README

संबंधित सोर्स रिपॉज़िटरी के मूल README का स्नैपशॉट। नवीनतम सामग्री के लिए रिपॉज़िटरी देखें।

mysql_utils

Pub

Flutter mysql plugin helps extend classes.

mysql_client has been abandoned and is now maintained by the author of this library. The new library is mysql_client_plus Pub。

If you use sqlite, you can also try sqlite_utils.

简体中文

Pub install

Install

New features [2.1.7]

  • Updated mysql_client_plus to version ^0.0.32
  • Updated settings from Map to MysqlUtilsSettings ⚠️⚠️⚠️
  • Added support for BLOB and JSON types
  • Added support for SSL certificates
  • Added support for calling stored procedures
  • Added support for sha256_password authentication
  • Added global debug option
  • Added tests
APIs
Initialization connection

Use the singleton mode, and call close() after use to close the database connection.

 var db = MysqlUtils(
  // ⚠️⚠️⚠️ settings from `Map` to `MysqlUtilsSettings`
  settings: MysqlUtilsSettings(
    // The hostname of the MySQL server, defaults to localhost.
    host: '127.0.0.1',
    // The port number to connect to, defaults to 3306.
    port: 3306,
    // The username to connect as, defaults to root.
    user: 'your_user_sha256',
    // The password to connect with, defaults to empty string.
    password: 'your_password_sha256',
    // The database to use, defaults to empty string.
    db: 'testdb',
    // Whether to use SSL, defaults to false.
    secure: true,
    // The prefix to use for table names, defaults to empty string.
    prefix: '',
    // The maximum number of connections to keep open, defaults to 1000.
    maxConnections: 1000,
    // The timeout in milliseconds for each connection, defaults to 10000.
    timeoutMs: 10000,
    // Whether to escape all queries, defaults to true.
    sqlEscape: true,
    // Whether to use a connection pool, defaults to false.
    pool: true,
    // The collation to use for all queries, defaults to utf8mb4_general_ci.
    collation: 'utf8mb4_general_ci',
    // Whether to use SSL, defaults to false.
    debug: true,
    // The SSL options to use for all queries, defaults to null.
    // securityContext: SecurityContext(),
    // sslMode: SslMode.require,
    // onBadCertificate: (certificate) => true,
  ),
  errorLog: (error) {
    print(error);
  },
  sqlLog: (sql) {
    print(sql);
  },
  connectInit: (db1) async {
    print('whenComplete');
  }
);
query

Native query

//var row = await db.query('select id from test_data2 where id=? or string_column like ?', whereValues: [1, '%串%'], isStmt: true);
var row = await db.query("select id from test_data2 where id=1 or string_column like '%mysql%'");
print(row.toMap());
print(row.toMap());
//// print(row.rowsAssoc.first.assoc());
// for (var item in row.rowsAssoc) {
//   print(item.assoc());
// }
// for (final row in row.rowsAssoc) {
//   print(row.colAt(0));
//   print(row.colByName("nickname"));
//   print(row.assoc());
// }
// db.close();
Multi table query

Query Multi data , multi-table query

var res = await db.getAll(
  table: 'user tb1,upload tb2',
  fields: 'tb2.fileSize',
  where: 'tb2.id>0 and tb2.uid=tb1.id',
  debug: true,
);
print(res);
getOne

Query one data

var row = await db.getOne(
  table: 'table',
  fields: '*',
  //excludeFields: 'telphone,image',
  //group: 'name',
  //having: 'name',
  //order: 'id desc',
  //limit: 10,//10 or '10 ,100'
//   where: {
//     'email': 'xxx@google.com',
//     'id': ['between', '1,4'],
//     'email2': ['=', 'sss@google.com'],
//     'news_title': ['like', '%name%'],
//     'user_id': ['>', 1],
//     'user_id': ['<', 1],
//     'user_id': ['<>', 1],
//     'user_id': ['=', 1],
//     'email3': ['!=', 'sss@google.com'],
//     '_SQL': '(`isNet`=1 OR `isNet`=2)',
//   },
  //where:'`id`=1 AND name like "%jame%"',
);
print(row);
getAll

Query multiple data


var row = await db.getAll(
  table: 'table',
  fields: '*',
  //excludeFields: 'telphone,image',
  //group: 'name',
  //having: 'name',
  //order: 'id desc',
  //limit: 10,//10 or '10 ,100'
//   where: {
//     'email': 'xxx@google.com',
//     'id': ['between', '1,4'],
//     'email2': ['=', 'sss@google.com'],
//     'news_title': ['like', '%name%'],
//     'user_id': ['>', 1],
//     '_SQL': '(`isNet`=1 OR `isNet`=2)',
//   },
  //where:'`id`=1 AND name like "%jame%"',
);
print(row);
insert

Add a data, return lastInsertID.

await db.insert(
  table: 'table',
  debug: false,
  insertData: {
    'telphone': '+113888888888',
    'email': 'teenagex@dd.com',
    'blob_data':Uint8List.fromList([0x48, 0x65, 0x6c, 0x6c, 0x6f]),
    'json_data':'{"name": "MysqlUtils"}',
    'date_data': '2025-01-01',
    'create_time': 1620577162252,
    'update_time': 1620577162252,
  },
);
insertAll

Add multiple data, return affectedRows.

 await db.insertAll(
  table: 'table',
  debug: false,
  insertData: [
      {
        'telphone': '13888888888',
        'create_time': 1111111,
        'update_time': 12121212,
        'email': 'teenagex@dd.com'
      },
      {
        'telphone': '13881231238',
        'create_time': 324234,
        'update_time': 898981,
        'email': 'xxx@dd.com'
      }
]);

update

Update data

await db.update(
  table: 'table',
  updateData:{
    'telphone': '1231',
    'create_time': 12,
    'update_time': 12121212,
    'email': 'teenagex@dd.com',
    'view_count': ['inc', 1], //or ['+', 1], 
    'first_view': ['dec', 1]  //or ['-', 1], 
  },
  where:{
  'id':1,
});
// update table set telphone='1231',create_time=12,update_time=12121212,email='teenagex@dd.com',view_count=view_count+1,first_view=first_view-1 where id=1;
delete

Delete data

await db.delete(
  table:'table',
  where: {'id':1}
);
count

Statistical data

await db.count(
  table: 'table',
  fields: '*',
  //group: 'name',
  //having: 'name',
);
avg
await db.avg(
  table: 'table',
  fields: 'price',
  //group: 'name',
  //having: 'name',
);
min
await db.min(
  table: 'table',
  fields: 'price',
  //group: 'name',
  //having: 'name',
);
max
await db.max(
  table: 'table',
  fields: 'price',
  //group: 'name',
  //having: 'name',
);
Transaction

Transaction support, In case of exception, transaction will roll back automatically.

await db.startTrans();
await db.delete(table: 'user', where: {'id': 25}, debug: true);
//await db.delete(table: 'user1', where: {'id': 26}, debug: true);
await db.commit();
await db.close();
isConnectionAlive

Connection is open or closed

var isAlive = await db.isConnectionAlive();
if (isAlive) print('mysql is isAlive');
Test
dart test

श्रेणियाँ

निर्भरताएँ

निर्भरता सूची 1 आइटम

  • mysql_client_plus^0.1.3

सोर्स रिपॉज़िटरी

इस पैकेज का उपयोग करने वाले प्रोजेक्ट

अभी कोई डेटा उपलब्ध नहीं है।