HYDatabaseManager 0.0.5

HYDatabaseManager 0.0.5

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Sep 2017

Maintained by Yan.


Downloads

Total25
Week0
Month3

Installs

Apps5
powered by Segment

GitHub

Stars0
Watchers1
Forks0
Issues0
Contributors1
Pull Requests0

Code

Files4
LOCLines of Code 195


  • By
  • Yan

Avoid multi thread makes the sqlite sleep.

Install

pod 'HYDatabaseManager'

pod install

Usage

NSString *sql = @"CREATE TABLE IF NOT EXISTS data ('id' INTEGER PRIMARY KEY AUTOINCREMENT  NOT NULL  UNIQUE, 'start' DATETIME, 'end' DATETIME);";
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSMutableArray *array = [NSMutableArray array];
        [array addObject:sql];
        for (int i = 0; i < 10000; i++) {
            [array addObject:@"INSERT into data (start, end) VALUES (1, 2)"];
        }
        // execute sqls
        [HYDatabaseManager executeSqls:[array copy] finished:^(BOOL result) {
            NSLog(@"finished");
        }];
        // select sqls results is dictionarys
        [HYDatabaseManager selectSql:@"SELECT * FROM data" keys:@[@"start"] finished:^(NSArray *results) {
            NSLog(@"end");
        }];
        // select sqls results is models
        [HYDatabaseManager selectSql:@"SELECT * FROM data limit 20" class:Model.class keys:@[@"start"] finished:^(NSArray *results) {
            for (Model *model in results) {
                NSLog(@"%@", model.start);
            }
        }];
    });