GithubHelp home page GithubHelp logo

vicwei127 / sqlite Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bujiandi/sqlite

0.0 2.0 0.0 639 KB

链式语法+泛型表枚举 封装的 SQLite 库, 面向协议编程

License: Other

Ruby 5.26% Makefile 0.99% Swift 93.65% Objective-C 0.09%

sqlite's Introduction

FFSQLite

特点

  • 使用Swift语言
  • 方便使用,链式语法。

使用

建立表模型

需继承DBTableType协议

enum UserInfo: String, DBTableType {

    static let table_name = "UserInfo"

    case userid
    case username
    case password
    case phonenum

    var type: DataBaseColumnType {
        switch self {
        case .userid:   return .Integer
        case .username: return .Text
        case .password: return .Text
        case .phonenum: return .Text
        }
    }
    var option: DataBaseColumnOptions {
        switch self {
        case .userid:   return .PrimaryKeyAutoincrement
        case .username: return .NotNull
        case .password: return .NotNull
        case .phonenum: return .None
        }
    }

}

单表查询

let sql = SQL<UserInfo>().SELECT.COUNT(.username, .phonenum, .username).FROM(UserInfo).WHERE(.username == 2)

多表查询

let sql = SQL2<UserInfo, PayInfo>()
sql.SELECT([.password, .phonenum], [.money, .product]).FROM(UserInfo.self, PayInfo.self).WHERE(.userid == .userid).AND(.money == .null)

关联查询

let sql = SELECT * FROM(UserInfo).LEFT.JOIN(PayInfo).ON(.userid == .userid).WHERE(.password != password)

删除数据

let sql = DELETE.FROM(PayInfo).WHERE(.userid == 5)

插入数据

let sql = INSERT.OR.REPLACE.INTO(UserInfo)[.userid, .password, .username].VALUES(1,”12345”,”fenfen”)

更新数据

let sql = UPDATE(PayInfo).SET(.money == 9, .product == "3322").WHERE(.money + 8 - 9 != 9)

License

FFSQLite is available under the MIT license. See [the LICENSE file](./LICENSE.txt) for more information.

sqlite's People

Contributors

bujiandi avatar cherishlau avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.