Introduction to SQLite

Source: Internet
Author: User
Tags sqlite

The first step:

Step Two, build the bridging filecasually create a class, the language chooses OC, and then it asks if you want to create a bridging mode, and then you choose Yes.that class can be deleted.add a sentence to the bridging file #import <sqlite3.h> then we can create a database or a table.//equivalent to C language pointersvar db:opaquepointer? = Nil//Create or open a databasefunc createoropendatabase () {print ("\ (Nshomedirectory ())") Let path:nsstring = "\ (documentspath)/test.sqlite3" as NSStringlet filename = path.utf8string if Sqlite3_open (filename, &db)! = SQLITE_OK {print ("Create or Open Failed ...")sqlite3_close (db)}}//Create student Tablesfunc createtable () {Let string:nsstring = "CREATE table if not exists Student (ID integer primary key autoincrement, sno text, name text, Score integer) "Let sql = string.utf8stringif SQLITE3_EXEC (db, SQL, nil, nil, nil)! = SQLITE_OK {print ("CREATE TABLE failed ...")sqlite3_close (db)}}

Introduction to SQLite

Related Article

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.