SQLite.swift 的封装 AutoSQLite.swift

码农软件 · 软件分类 · 其他开发相关 · 2019-10-17 12:42:57

软件介绍

SQLite.swift的封装,使用swift的反射原理,Model直接存储.获取. 无需再转换,增删改查. 脱离sql语句,不需要添加相关的绑定操作,直接完成转换。


使用方法

  • 1、引入source目录下的文件文件:

SQLiteModel.swift

SQLiteDataBase.swift

SQLiteDataBaseTool.swift

SQLMirrorModel.swift

SQLPropertyModel.swift

创建model继承SQLiteModel即可
  • 2、使用以下方法

        // 创建dataBase,

        var manager = SQLiteDataBase.createDB("testDataBaseName")
        // 插入

        manager.insert(object: testModel, intoTable: "testTableName")

        或者

        SQLiteDataBase.insert(object: testModel, intoTable: "testTableName")
        // 删除

        manager.delete(testModel, fromTable: "testTableName")

        或者

        SQLiteDataBase.deleteModel(testModel, fromTable: "testTableName")
        // 更新

        testModel.name = "Reet"

        manager.update(testModel, fromTable: "testTableName")

        或者

        SQLiteDataBase.update(testModel, fromTable: "testTableName")
        // 查询

        guard let results = manager.select(testModel, fromTable: "testTableName") else {

            print("没有查询到数据")

            return

        }

        for result in results {

            print("查询的数据\(result)")

        }

        或者

        let results = SQLiteDataBase.select(testModel, fromTable: "testTableName")

        if results.count > 0{

            for result in results {

                print("查询的数据\(result)")

            }

        }else {

            print("没有查询到数据")

        }

本文地址:https://codercto.com/soft/d/16951.html

Hackers

Hackers

Steven Levy / O'Reilly Media / 2010-5-30 / USD 21.99

This 25th anniversary edition of Steven Levy's classic book traces the exploits of the computer revolution's original hackers -- those brilliant and eccentric nerds from the late 1950s through the ear......一起来看看 《Hackers》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

URL 编码/解码
URL 编码/解码

URL 编码/解码

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换