DB database extracts and parses data using a third-party framework

Source: Internet
Author: User

DB packets are parsed and extracted from a three-party framework downloaded from GitHub, typically in the form of arrays and dictionaries. DB's viewing tool is the parse DB plugin on Firefox, SQLite

Three-party framework for Fmdb

#import "ViewController.h"//1. Introduction of header file, need to introduce Libsqlite3 library #import "FMDB.h" #import "Word.h" @interface Viewcontroller () @end @implementation Viewcont        roller-(void) viewdidload {[Super viewdidload]; 2.    Create a Fmdatabase object and specify the file path fmdatabase *database = [fmdatabase databasewithpath:@ "/users/apple/desktop/japanese.db"]; 3. Open File if (![        Database Open] {NSLog (@ "Can not open File");    Return }//4.        Execute query fmresultset *result = [Database executequery:@ "SELECT * from JP"];    Nsmutablearray *array = [Nsmutablearray array]; 5.                Gets a row in the table while ([result next]) {//Nsmutabledictionary *dict = [Nsmutabledictionary dictionary];                Word *word = [[Word alloc] init];        Gets the data int rid = [result intforcolumn:@ "id"] according to the name (column name);                NSLog (@ "RID:%d", RID);        Word.rid = RID;                [Dict setobject:[nsnumber Numberwithint:rid] forkey:@ "id"]; Get data int based on location RID1 = [result intforcolumnindex:0];                NSLog (@ "RID1:%d", RID1);        NSString *kana = [result stringforcolumn:@ "kana"];        NSLog (@ "kana:%@", kana);                [Dict setobject:kana forkey:@ "Kana"];        NSString *KANA1 = [result stringforcolumnindex:5];                NSLog (@ "KANA1:%@", KANA1);                Word.kana = KANA1;    [Array Addobject:word]; }//6.        Close file [Database close];    NSLog (@ "-----------"); NSLog (@ "%@", array);}



This is the code in Word.h and WORD.M.

#import <Foundation/Foundation.h> @interface Word:nsobject@property (nonatomic, assign) Nsinteger RIDs; @property (nonatomic, copy) NSString *kana; @end

#import "Word.h" @implementation word-(NSString *) description{    return [NSString stringwithformat:@ "%@: RID:% d---Kana:%@ ", [Super description], _rid, _kana];} @end


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.