{"id":21916784,"url":"https://github.com/ccworld1000/ccsqlite","last_synced_at":"2026-04-12T01:44:35.248Z","repository":{"id":56904356,"uuid":"81716520","full_name":"ccworld1000/CCSQLite","owner":"ccworld1000","description":"CCSQLite A Cocoa / Objective-C wrapper around SQLite. YapDatabase(key/value store) + FMDB. CCSQLite Objective-C 封装的SQLite. 结合YapDatabase(key/value store) + FMDB.【Support macOSX and iOS】.","archived":false,"fork":false,"pushed_at":"2020-06-29T04:25:00.000Z","size":370,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-07T23:29:06.024Z","etag":null,"topics":["cache","ccsqlite","fmdb","lightweight-cache","lightweight-data","sqlite","swift","yap-database","yapdatabase","yapdatabase-key"],"latest_commit_sha":null,"homepage":"https://github.com/ccworld1000/CCSQLite","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ccworld1000.png","metadata":{"files":{"readme":"README.CN.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-12T09:49:03.000Z","updated_at":"2025-06-02T21:59:32.000Z","dependencies_parsed_at":"2022-08-21T02:50:21.974Z","dependency_job_id":null,"html_url":"https://github.com/ccworld1000/CCSQLite","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/ccworld1000/CCSQLite","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccworld1000%2FCCSQLite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccworld1000%2FCCSQLite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccworld1000%2FCCSQLite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccworld1000%2FCCSQLite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ccworld1000","download_url":"https://codeload.github.com/ccworld1000/CCSQLite/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccworld1000%2FCCSQLite/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266465099,"owners_count":23933065,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cache","ccsqlite","fmdb","lightweight-cache","lightweight-data","sqlite","swift","yap-database","yapdatabase","yapdatabase-key"],"created_at":"2024-11-28T19:20:07.870Z","updated_at":"2026-04-12T01:44:35.207Z","avatar_url":"https://github.com/ccworld1000.png","language":"Objective-C","readme":"[![Platform](https://img.shields.io/badge/platforms-iOS%20%7C%20OSX-orange.svg)](https://github.com/ccworld1000/CCSQLite.git)\n[![Languages](https://img.shields.io/badge/languages-ObjC-orange.svg)](https://github.com/ccworld1000/CCSQLite)\n![Swift 5.3.0.x](https://img.shields.io/badge/Swift-5.3.0.x-orange.svg)\n[![Version](https://img.shields.io/cocoapods/v/CCSQLite.svg)](https://github.com/ccworld1000/CCSQLite.git)\n[![License](https://img.shields.io/cocoapods/l/CCSQLite.svg)](https://github.com/ccworld1000/CCSQLite/blob/master/LICENSE/LICENSE.CCSQLite.txt)\n\n### CCSQLite Objective-C 封装的SQLite. 结合YapDatabase(key/value store) + FMDB.\n\n###  [CCSQLite](https://github.com/ccworld1000/CCSQLite)\n***\n[英文README](README.md)\n\n***\n# 目的\n* 转变 FMDB 到 ARC 模式\n* YapDatabase 键/值 store \n* CCSQLite 结合 FMDB 和 YapDatabase 键/值 \n\n***\n###  目的\n* 转变 FMDB 到 ARC 模式\n* YapDatabase 键/值 store  \n* CCSQLite 结合 FMDB 和 YapDatabase 键/值\n* 支持 OBJECT, JSON 到 键/值\n\n***\n\n***\n# 缘由 \u0026\u0026 为啥\n***\n当我在写\"HSCache [缓存处理方面]\", 想选择FMDB或者YapDatabase, 但是他们看起来不一样. 因此想结合YapDatabase(键/值 store) 与 FMDB, 于是 CCSQLite 在路上.\n\n\n###  大于版本 1.1.1调整变化\n***\n![CCSQLite CCSQLiteMac Screenshot](https://github.com/ccworld1000/CCSQLite/blob/master/Documentation/MainAdjust.png?raw=true)\n\n###  Podfile\n\n```ruby\npod 'CCSQLite'\n```\n\n***\n\n### 演示\n\n#### for Objective-C\n##### see CCSQLiteDemo\n##### iOS CCSQLiteiOSDemo\n##### OSX CCSQLiteOSXDemo\n\n### for Swift call Objective-C\n##### iOS CCSQLiteDataiOS\n##### OSX CCSQLiteDatamacOS\n\n### 演示代码\n```objective-c\n#import \u003cCCSQLite.h\u003e\n```\nor\n\n```objective-c\n#import \"CCSQLite.h\"\n```\nor\n\n```objective-c\n#import \"CCSQLite/CCSQLite.h\"\n```\n\n\n```objective-c\n+ (void) SQLiteTest {\n    NSLog(@\"SQLiteTest\");\n    \n    NSString *path = nil;\n#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR\n    path = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES)  lastObject];\n#else\n    path = NSTemporaryDirectory() ;\n#endif\n    \n    path = [path stringByAppendingPathComponent:CCSQLiteTestDB];\n    \n    if ([[NSFileManager defaultManager] fileExistsAtPath:path]) {\n        [[NSFileManager defaultManager] removeItemAtPath:path error: nil];\n    }\n    \n    CCSQLite *SQLite = [CCSQLite databaseWithPath: path];\n\n    if ([SQLite open]) {\n        BOOL result = [SQLite executeUpdate: @\"create table if not exists t_student (id integer primary key autoincrement, name text not NULL, age integer not NULL);\"];\n        if (result) {\n            NSLog(@\"create table t_student ok\");\n            NSLog(@\"path : %@\", path);\n       }\n    }\n    \n    [SQLite executeUpdate:@\"insert into t_student (name, age) values (?, ?);\", @\"cc test 0\", @0];\n    [SQLite executeUpdate:@\"insert into t_student (name, age) values (?, ?);\", @\"cc test 1\", @1];\n    [SQLite executeUpdateWithFormat:@\"insert into t_student (name, age) values (%@, %i);\", @\"cc test 2\", 2000];\n    \n//    [SQLite executeUpdate:@\"delete from t_student where id = ?\", @1];\n    \n    CCResultSet *resultSet = [SQLite executeQuery:@\"select * from t_student;\"];\n    while ([resultSet next]) {\n        int idNum = [resultSet intForColumn:@\"id\"];\n        NSString *name = [resultSet objectForColumnName:@\"name\"];\n        int age = [resultSet intForColumn:@\"age\"];\n        \n        NSLog(@\"id = %d name = %@ age = %d\", idNum, name, age);\n    }\n    \n//    [SQLite executeUpdate:@\"drop table if exists t_student;\"];\n    \n    NSString *sql = @\"create table bulktest1 (id integer primary key autoincrement, x text);\"\n    \"create table bulktest2 (id integer primary key autoincrement, y text);\"\n    \"create table bulktest3 (id integer primary key autoincrement, z text);\"\n    \"insert into bulktest1 (x) values ('XXX');\"\n    \"insert into bulktest2 (y) values ('YYY');\"\n    \"insert into bulktest3 (z) values ('ZZZ');\";\n    \n    BOOL success = [SQLite executeStatements:sql];\n    \n    if (success) {\n        NSLog(@\"success\");\n    }\n    \n    sql = @\"select count(*) as count from bulktest1;\"\n    \"select count(*) as count from bulktest2;\"\n    \"select count(*) as count from bulktest3;\";\n    \n    [SQLite executeStatements:sql withResultBlock:^int(NSDictionary *resultsDictionary) {\n        NSInteger count = [resultsDictionary[@\"count\"] integerValue];\n        NSLog(@\"count = %ld\", count);\n        return 0;\n    }];\n    \n    [SQLite close];\n    \n    CCSQLiteQueue *queue = [CCSQLiteQueue databaseQueueWithPath:path];\n    \n    __block NSInteger index = 3000;\n    [queue inDatabase:^(CCSQLite *db) {\n        while (index \u003c 3100) {\n            index++;\n            [db executeUpdate:@\"insert into t_student (name, age) values (?, ?);\", [NSString stringWithFormat:@\"cc test inDatabase %ld\", index], @(index)];\n        }\n\n    }];\n    \n    [queue inTransaction:^(CCSQLite *db, BOOL *rollback) {\n        NSLog(@\"rollback NO\");\n        while (index \u003c 3150) {\n            index++;\n            [db executeUpdate:@\"insert into t_student (name, age) values (?, ?);\", [NSString stringWithFormat:@\"cc test inTransaction %ld\", index], @(index)];\n        }\n    }];\n    \n    [queue inTransaction:^(CCSQLite *db, BOOL *rollback) {\n        NSLog(@\"rollback YES\");\n        while (index \u003c 3200) {\n            index++;\n            [db executeUpdate:@\"insert into t_student (name, age) values (?, ?);\", [NSString stringWithFormat:@\"cc test inTransaction %ld\", index], @(index)];\n            \n            if (index == 3188) {\n                *rollback = YES;\n                return ;\n            }\n        }\n    }];\n}\n\n```\n\n### CCKeyValue 演示代码\n```objective-c\n    CCKeyValue *kv = [CCKeyValue defaultKeyValueWithPath:path];\n    kv.valueType = CCKeyValueTypeJson;\n    \n    NSData * data = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@\"CCJSON\" ofType:@\"json\"]];\n    \n    [kv setObject:data key:@\"jsonkey\"];\n    \n    id CCJSON =  [kv objectForKey:@\"jsonkey\"];\n    \n    if ([CCJSON isKindOfClass:[NSArray class]]) {\n        NSArray *list = CCJSON;\n        \n        [list enumerateObjectsUsingBlock:^(NSDictionary *d, NSUInteger idx, BOOL * _Nonnull stop) {\n            NSLog(@\"%@\\n\", d);\n        }];\n    }\n```\n结果\n![CCKeyValue Screenshot](https://github.com/ccworld1000/CCSQLite/blob/master/Documentation/CCKeyValue.png?raw=true)\n\n### Swift 调用 Objective-C\n\n```swift\n    override func viewDidLoad() {\n        super.viewDidLoad()\n        // Do any additional setup after loading the view, typically from a nib.\n        \n        CCSQLiteData.writeList()\n        if let list = CCSQLiteData.readList() {\n            print(list)\n        }\n    }\n```\n\n### MIT 许可证\n***\n\nMIT License\n\nCopyright (c) 2016-now ccworld1000 | bug : \u003ca href=\"mailto:ccworld1000@gmail.com\"\u003eccworld1000@gmail.com\u003c/a\u003e\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n***\n### 其他许可证\n***\n\n[FMDB LICENSE](LICENSE/LICENSE.FMDB.txt) \n\n[YapDatabase LICENSE](LICENSE/LICENSE.YapDatabase.txt) \n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fccworld1000%2Fccsqlite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fccworld1000%2Fccsqlite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fccworld1000%2Fccsqlite/lists"}