Latest 0.1.3
License MIT
Platforms ios 7.0, requires ARC
Dependencies FMDB

GSSqlHelper is a sql helper class. Be similar to SQLiteHelper class in Android.

It use FMDB to support operate sqlite.

In iOS SDK,I can not find a class that can create or upgrate database like SQLiteHelper in Android, So I do it.


You can use GSSqlHelper directly ,but I strongly propose inherit it.


  1. Update cocoapods to the latest version.
  2. Add pod ‘GSSqlHelper’ to your Podfile.
#import "GSSqlHelper.h"
@interface TestDbHelper : GSSqlHelper
+(TestDbHelper *)instances;

#import "TestDbHelper.h"
@implementation YBTDbHelper
- (void)onCreateDb:(FMDatabase *)db{
    //when create a new db, this method will be call.
- (void)onUpgradeDb:(FMDatabase *)db FromOldDbVersion:(NSInteger)oldVersion toNewDbVersion:(NSInteger)newVersion{
    //when db need to upgrade,this method will be call.
+(TestDbHelper *)instances{
    static TestDbHelper *dbHelper;
    static dispatch_once_t onceToken;
        NSString *strDbName = @"testDb";
        NSInteger newDbVersion = 0;
        NSString *dbname = [NSString stringWithFormat:@"%@",strDbName];
        dbHelper = [[TestDbHelper alloc]initWithDbName:dbname Version:newDbVersion];
    return dbHelper;

TestDbHelper *dbhelper = [TestDbHelper instances];
 [dbhelper.dbQueue inDatabase:^(FMDatabase *db) {
        //operate db here.

Latest podspec

    "name": "GSSqlHelper",
    "version": "0.1.3",
    "summary": "a sqlite helper class that like SQLiteHelper in Android",
    "homepage": "",
    "license": "MIT",
    "authors": {
        "gscool": "[email protected]"
    "platforms": {
        "ios": "7.0"
    "source": {
        "git": "",
        "tag": "0.1.3"
    "source_files": "GSSqlHelper/*.{h,m}",
    "requires_arc": true,
    "dependencies": {
        "FMDB": []

Pin It on Pinterest

Share This