sqlite_utils

Creator: coderz1093

Last updated:

0 purchases

TODO
Add to Cart

Description:

sqlite utils

sqlite_utils #

Flutter sqlite plugin helps extend classes.
简体中文
Pub install #
Install
APIs #
Initialization connection
var db = SqliteUtils(settings: {
'database': 'loop.db',
'tableMap': {
'table1':'id INTEGER PRIMARY KEY, nickname TEXT, telphone TEXT, createTime INTEGER, updateTime INTEGER',
'table2': 'id INTEGER PRIMARY KEY, title TEXT, titleId INTEGER',
},
'version': 1,
});
copied to clipboard
query
var row = await db
.query('select * from table id=1');
print(row);
// db.close();
copied to clipboard
getAll(getOne) Multi table
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);
copied to clipboard
getOne
Query one data
var row = await db.getOne(
table: 'table',
fields: '*',
//group: 'name',
//having: 'name',
//order: 'id desc',
//limit: 10,//10 or '10 ,100'
//where: 'email=xxx@google.com',
where: {'email': 'xxx@google.com'},
);
print(row);
copied to clipboard
getAll
Query multiple data

var row = await db.getAll(
table: 'table',
fields: '*',
//group: 'name',
//having: 'name',
//order: 'id desc',
//limit: 10,//10 or '10 ,100'
where: {
'email': 'xxx@dd.com',
//'id': ['between', 0, 1],
//'id': ['notbetween', 0, 2],
//'id': ['in', [1,2,3]],
//'id': ['notin', [1,2,3]],
//'email': ['=', 'sss@cc.com'],
//'news_title': ['like', '%name%'],
//'user_id': ['>', 1],
},
);
print(row);
copied to clipboard
insert
Add a data
await db.insert(
table: 'table',
insertData: {
'telphone': '+113888888888',
'create_time': 1620577162252,
'update_time': 1620577162252,
},
);
copied to clipboard
insertAll
Add multiple data
await db.insertAll(
table: 'table',
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'
}
]);

copied to clipboard
update
Update data
await db.update(
table: 'table',
updateData:{
'telphone': '1231',
'create_time': 12,
'update_time': 12121212,
'email': 'teenagex@dd.com'
},
where:{
'id':1,
});
copied to clipboard
delete
Delete data
await db.delete(
table:'table',
where: {'id':1}
);
copied to clipboard
count
Statistical data
await db.count(
table: 'table',
fields: '*',
//group: 'name',
//having: 'name',
);
copied to clipboard
demo test
cd example
dart run lib/main.dart
copied to clipboard

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.