Coder Social home page Coder Social logo

micah2015 / sqlite Goto Github PK

View Code? Open in Web Editor NEW

This project forked from logoove/sqlite

0.0 0.0 0.0 11.4 MB

一个不使用cgo的database/sql标准sqlite3驱动,原驱动`modernc.org/sqlite`,但是速度不行,搬迁过来,同时修改了驱动名称为sqlite3,这样就能在goframe和其他框架中使用.

License: BSD 3-Clause "New" or "Revised" License

Go 98.67% Makefile 1.33%

sqlite's Introduction

sqlite

一个不使用cgo的database/sql标准sqlite3驱动,原驱动modernc.org/sqlite,但是速度不行,在github上边没有,就从gitlab搬迁过来,同时修改了驱动名称为sqlite3,这样不用任何修改,就能在goframe框架中使用.

非框架使用方法

	"github.com/jmoiron/sqlx"
	_ "github.com/logoove/sqlite"
    
  var db *sqlx.DB

type User struct {
	Id   int64  `db:"id"`
	Name string `db:"name"`
}

func main() {
	db, _ = sqlx.Open("sqlite3", "./db.db")
	db.Exec(`CREATE TABLE users (
  "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
  "name" char(15) NOT NULL
);`)
	db.Exec(`insert into users(name) values(?)`, "李白")
	db.Exec(`insert into users(name) values(?)`, "白居易")
	var rows []User
	db.Select(&rows, "SELECT id,name FROM users ORDER BY id")
	fmt.Println(rows)
}  

goframe1.17

配置在config/config.toml

[database]
	type= "sqlite"
    link= "./public/resource/db.db"
    debug = true

然后在boot 下面boot.go文件里面加上

_ "github.com/logoove/sqlite"

goframe2.0

在manifeat/config/config.yaml配置

# 数据库连接配置
database:
  logger:
    path:    "./temp/logs/sql"
    level:   "all"
    stdout:  true
    ctxKeys: ["RequestId"]
  default:
    type: "sqlite"
    link: "./resource/db.db" #数据库路径根据自己的填写
    debug:  true

在internel/cmd文件夹中放入sqlite.go驱动文件,已经将驱动改成sqlite3,所以能够直接在goframe2.0中使用.驱动文件在examples里面

插入数据两个goframe版本一样

id, _ := g.Model("user").Data(g.Map{"name": "john", "age": 1}).InsertAndGetId()

examples是例子

gf17是gf1.7 gflay是gf2.0 sqlx是不使用框架 sqlite.go是gf2.0驱动

更新日志

2022-3-22 v1.15.3 新增win amd64编译,解决内存泄漏问题.

2021-11-3 v1.13.0 新增更多系统编译,支持sqlite 3.36.0

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.