Operating the database with the Sqlite.swift Open Source Library

Source: Internet
Author: User
Tags sqlite database


Because the SQLite database was used in the iOS project, looking for a supported library on GitHub, the library was found


Https://github.com/stephencelis/SQLite.swift


Follow the instructions in the documentation to download the project and attach it to your project


And then import this module into your own project.

Import SQLite


The simple syntax, the first to initialize the library, for example, I use an external library, follow the path to open

let db=Database(path,readonly:true)

and set it to read-only


Initializing tables


let brand=db["brand"]

let car_brand=db["Car_brand"]

let color=db["Color"]

let vehicle_type=db["Vehicle_type"]



Then initialize the field, where only the fields in the brand table are initialized


             let brand_id = expression < "id"

            let Brand_abb = expression < string > (

let brand_name = Expression<String> (" Car_name ")



It can then be quid operation, the type of the field must be correct, otherwise it will be an error


See official documentation for details


Https://github.com/stephencelis/SQLite.swift/blob/master/Documentation/Index.md




From for notes (Wiz)

Operating the database with the Sqlite.swift Open Source Library

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.