100+ results for 'lang:go SetMaxOpenConns sqlite'

Not the results you expected?

db.go (https://github.com/photoprism/photoprism.git) Go · 194 lines

11 "github.com/jinzhu/gorm"

12 _ "github.com/jinzhu/gorm/dialects/mysql"

13 _ "github.com/jinzhu/gorm/dialects/sqlite"

14 "github.com/photoprism/photoprism/internal/entity"

15 "github.com/photoprism/photoprism/internal/mutex"

21 case MySQL, "mariadb":

22 c.params.DatabaseDriver = MySQL

23 case SQLite, "sqlite", "sqllite", "test", "file", "":

24 c.params.DatabaseDriver = SQLite

25 case "tidb":

26 log.Warnf("config: database driver 'tidb' is deprecated, using sqlite")

27 c.params.DatabaseDriver = SQLite

28 c.params.DatabaseDsn = ""

29 default:

30 log.Warnf("config: unsupported database driver %s, using sqlite", c.params.DatabaseDriver)

31 c.params.DatabaseDriver = SQLite

model.go (https://github.com/ouqiang/gocron.git) Go · 143 lines

79 }

80 engine.SetMaxIdleConns(app.Setting.Db.MaxIdleConns)

81 engine.SetMaxOpenConns(app.Setting.Db.MaxOpenConns)

82 engine.SetConnMaxLifetime(dbMaxLiftTime)

83

rel_store.go (https://github.com/github/orchestrator.git) Go · 249 lines

76 if relStore.backend == nil {

77 relStoreFile := filepath.Join(relStore.dataDir, raftStoreFile)

78 sqliteDB, _, err := sqlutils.GetSQLiteDB(relStoreFile)

79 if err != nil {

80 return nil, err

81 }

82 sqliteDB.SetMaxOpenConns(1)

83 sqliteDB.SetMaxIdleConns(1)

84 for _, query := range createQueries {

85 if _, err := sqliteDB.Exec(sqlutils.ToSqlite3Dialect(query)); err != nil {

86 return nil, err

87 }

88 }

89 relStore.backend = sqliteDB

90 log.Infof("raft: store initialized at %+v", relStoreFile)

91 }

sqldb.go (https://github.com/haydenwoodhead/burner.kiwi.git) Go · 187 lines

20 func New(dbType string, dbURL string) *SQLDatabase {

21 s := &SQLDatabase{sqlx.MustOpen(dbType, dbURL), dbType}

22 if dbType == "sqlite3" {

23 s.SetMaxOpenConns(1)

connection.go (https://gitlab.com/mikattack/linksink) Go · 107 lines

5 "strings"

6

7 _ "github.com/mattn/go-sqlite3"

8 "github.com/jmoiron/sqlx"

9 )

19

20 /*

21 * Initializes a SQLite database

22 */

23 func InitializeDatabasePool(path string) (*sqlx.DB, error) {

32

33 // Open database file

34 db, err := sqlx.Open("sqlite3", path)

35 if err != nil {

36 return connection, err

db.go (https://github.com/matrix-org/go-neb.git) Go · 353 lines

41 return

42 }

43 if databaseType == "sqlite3" {

44 // Fix for "database is locked" errors

45 // https://github.com/mattn/go-sqlite3/issues/274

46 db.SetMaxOpenConns(1)

47 }

48 serviceDB = &ServiceDB{db: db, dialect: databaseType}

329 }

330

331 // GetSQLDb retrieves the SQL database instance of a ServiceDB and the dialect it uses (sqlite3 or postgres).

332 func (d *ServiceDB) GetSQLDb() (*sql.DB, string) {

333 return d.db, d.dialect

mysql.go (https://github.com/Azareal/Gosora.git) Go · 82 lines

40 // Set the number of max open connections

41 db = qgen.Builder.GetConn()

42 db.SetMaxOpenConns(64)

43 db.SetMaxIdleConns(32)

44 //db.SetConnMaxLifetime(time.Second * 60 * 5) // Just in case we accumulate some bad connections due to the MySQL driver being stupid

48 db.SetConnMaxLifetime(c.DBTimeout())

49

50 // Build the generated prepared statements, we are going to slowly move the queries over to the query generator rather than writing them all by hand, this'll make it easier for us to implement database adapters for other databases like PostgreSQL, MSSQL, SQlite, etc.

51 err = _gen_mysql()

52 if err != nil {

gorm.go (https://github.com/flipped-aurora/gin-vue-admin.git) Go · 146 lines

22 case "postgresql":

23 GormPostgreSql()

24 //case "sqlite": // sqlite需要gcc支持 windows用户需要自行安装gcc 如需使用打开注释即可

25 // GormSqlite()

76 sqlDB, _ := global.GVA_DB.DB()

77 sqlDB.SetMaxIdleConns(m.MaxIdleConns)

78 sqlDB.SetMaxOpenConns(m.MaxOpenConns)

79 }

80 }

96 sqlDB, _ := global.GVA_DB.DB()

97 sqlDB.SetMaxIdleConns(p.MaxIdleConns)

98 sqlDB.SetMaxOpenConns(p.MaxOpenConns)

99 }

100 }

101

102 // GormSqlite 初始化Sqlite数据库 sqlite需要gcc支持 windows用户需要自行安装gcc 如需使用打开注释即可

103 //func GormSqlite() {

database.go (https://github.com/stashapp/stash.git) Go · 232 lines

10 "github.com/gobuffalo/packr/v2"

11 "github.com/golang-migrate/migrate/v4"

12 sqlite3mig "github.com/golang-migrate/migrate/v4/database/sqlite3"

13 "github.com/golang-migrate/migrate/v4/source"

14 "github.com/jmoiron/sqlx"

15 sqlite3 "github.com/mattn/go-sqlite3"

16 "github.com/stashapp/stash/pkg/logger"

17 "github.com/stashapp/stash/pkg/utils"

23 var databaseSchemaVersion uint

24

25 const sqlite3Driver = "sqlite3ex"

26

27 func init() {

conn.go (https://gitlab.com/github-cloud-corporation/dex) Go · 110 lines

34 DSN string

35 // The maximum number of open connections to the database. The default is 0 (unlimited).

36 // For more details see: http://golang.org/pkg/database/sql/#DB.SetMaxOpenConns

37 MaxOpenConnections int

38 // The maximum number of connections in the idle connection pool. The default is 0 (unlimited).

57 }

58 db.SetMaxIdleConns(cfg.MaxIdleConnections)

59 db.SetMaxOpenConns(cfg.MaxOpenConnections)

60 dialect = gorp.PostgresDialect{}

61 case "sqlite3":

62 db, err = sql.Open("sqlite3", u.Host)

63 if err != nil {

64 return nil, err

65 }

66 if u.Host == ":memory:" {

67 // NOTE(ericchiang): sqlite3 coordinates concurrent clients through file locks.

68 // In memory databases do not support concurrent calls. Limit the number of

69 // open connections to 1.

sql.go (https://github.com/haifenghuang/monkey.git) Go · 755 lines

4 "database/sql"

5 _ "fmt"

6 // _ "github.com/mattn/go-sqlite3"

7 _ "reflect"

8 )

73 case "close":

74 return s.Close(line, args...)

75 case "setMaxOpenConns":

76 return s.SetMaxOpenConns(line, args...)

117 }

118

119 func (s *SqlObject) SetMaxOpenConns(line string, args ...Object) Object {

120 if len(args) != 1 {

121 panic(NewError(line, ARGUMENTERROR, "0", len(args)))

124 n, ok := args[0].(*Integer)

125 if !ok {

126 panic(NewError(line, PARAMTYPEERROR, "first", "setMaxOpenConns", "*Integer", args[0].Type()))

127 }

128

database.go (https://github.com/gotify/server.git) Go · 107 lines

11 _ "github.com/jinzhu/gorm/dialects/mysql" // enable the mysql dialect

12 _ "github.com/jinzhu/gorm/dialects/postgres" // enable the postgres dialect

13 _ "github.com/jinzhu/gorm/dialects/sqlite" // enable the sqlite3 dialect

14 )

15

18 // New creates a new wrapper for the gorm database framework.

19 func New(dialect, connection, defaultUser, defaultPass string, strength int, createDefaultUserIfNotExist bool) (*GormDatabase, error) {

20 createDirectoryIfSqlite(dialect, connection)

21

22 db, err := gorm.Open(dialect, connection)

27 // We normally don't need that much connections, so we limit them. F.ex. mysql complains about

28 // "too many connections", while load testing Gotify.

29 db.DB().SetMaxOpenConns(10)

30

31 if dialect == "sqlite3" {

store.go (https://github.com/rancher/k3s.git) Go · 231 lines

13

14 "github.com/canonical/go-dqlite/internal/protocol"

15 _ "github.com/mattn/go-sqlite3" // Go SQLite bindings

16 )

17

42

43 // DefaultNodeStore creates a new NodeStore using the given filename to

44 // open a SQLite database, with default names for the schema, table and column

45 // parameters.

46 //

48 func DefaultNodeStore(filename string) (*DatabaseNodeStore, error) {

49 // Open the database.

50 db, err := sql.Open("sqlite3", filename)

51 if err != nil {

52 return nil, errors.Wrap(err, "failed to open database")

connection_details.go (https://github.com/arschles/go-in-5-minutes.git) Go · 142 lines

16 // ConnectionDetails stores the data needed to connect to a datasource

17 type ConnectionDetails struct {

18 // Example: "postgres" or "sqlite3" or "mysql"

19 Dialect string

20 // The name of your database. Example: "foo_development"

33 // database. Example: "postgres://postgres:postgres@localhost:5432/pop_test?sslmode=disable"

34 URL string

35 // Defaults to 0 "unlimited". See https://golang.org/pkg/database/sql/#DB.SetMaxOpenConns

36 Pool int

37 Options map[string]string

51 }

52 cd.Database = cd.URL

53 if !strings.HasPrefix(cd.Dialect, "sqlite") {

54 u, err := url.Parse(ul)

55 if err != nil {

110 cd.Database = strings.TrimPrefix(cd.Database, "/")

111 }

112 case "sqlite", "sqlite3":

113 cd.Dialect = "sqlite3"

sqlite.go (https://github.com/smancke/guble.git) Go · 109 lines

20 sqliteMaxOpenConns = 5

21 sqliteGormLogMode = false

22 )

23

24 var writeTestFilename = "db_testfile"

25

26 // SqliteKVStore is a struct representing a sqlite database which embeds a kvStore.

27 type SqliteKVStore struct {

33 // NewSqliteKVStore returns a new configured SqliteKVStore (not opened yet).

34 func NewSqliteKVStore(filename string, syncOnWrite bool) *SqliteKVStore {

35 return &SqliteKVStore{

70 gormdb.DB().SetMaxIdleConns(sqliteMaxIdleConns)

71 gormdb.DB().SetMaxOpenConns(sqliteMaxOpenConns)

72

73 if err := gormdb.AutoMigrate(&kvEntry{}).Error; err != nil {

storage.go (https://github.com/matrix-org/dendrite.git) Go · 175 lines

14 // limitations under the License.

15

16 package sqlite3

17

18 import (

27 "github.com/matrix-org/dendrite/roomserver/types"

28 "github.com/matrix-org/gomatrixserverlib"

29 _ "github.com/mattn/go-sqlite3"

30 )

31

46 }

47

48 // Open a sqlite database.

49 // nolint: gocyclo

50 func Open(dbProperties *config.DatabaseOptions, cache caching.RoomServerCaches) (*Database, error) {

db.go (https://github.com/88250/pipe.git) Go · 94 lines

21 _ "github.com/jinzhu/gorm/dialects/mysql"

22 _ "github.com/jinzhu/gorm/dialects/postgres"

23 _ "github.com/jinzhu/gorm/dialects/sqlite"

24 )

25

28

29 var db *gorm.DB

30 var useSQLite, useMySQL, usePostgres bool

31

32 // ConnectDB connects to the database.

33 func ConnectDB() {

34 var err error

35 useSQLite = false

36 useMySQL = false

37 usePostgres = false

38 if "" != model.Conf.SQLite {

39 db, err = gorm.Open("sqlite3", model.Conf.SQLite)

40 useSQLite = true

service.go (https://github.com/henrylee2cn/faygo.git) Go · 86 lines

13 _ "github.com/lib/pq" //postgres

14 // _ "github.com/mattn/go-oci8" //oracle(need to install the pkg-config utility)

15 // _ "github.com/mattn/go-sqlite3" //sqlite

16

17 "github.com/henrylee2cn/faygo"

56 }

57

58 db.SetMaxOpenConns(conf.MaxOpenConns)

59 db.SetMaxIdleConns(conf.MaxIdleConns)

60

67 db.Mapper = reflectx.NewMapperFunc(conf.StructTag, strFunc)

68

69 if conf.Driver == "sqlite3" && !faygo.FileExists(conf.Connstring) {

70 os.MkdirAll(filepath.Dir(conf.Connstring), 0777)

71 f, err := os.Create(conf.Connstring)

test_db.go (https://github.com/go-reform/reform.git) Go · 155 lines

9 "time"

10

11 sqlite3Driver "github.com/mattn/go-sqlite3"

12

13 "gopkg.in/reform.v1"

35

36 // register custom function "sleep" for context tests

37 if driver == "sqlite3" {

38 driver = "sqlite3_with_sleep"

43 return nsec, nil

44 }

45 sql.Register(driver, &sqlite3Driver.SQLiteDriver{

46 ConnectHook: func(conn *sqlite3Driver.SQLiteConn) error {

119

120 var version, sourceID string

121 if err = db.QueryRow("SELECT sqlite_version(), sqlite_source_id()").Scan(&version, &sourceID); err != nil {

122 log.Fatal(err)

123 }

gorose.go (https://github.com/yxhsea/SecKill.git) Go · 263 lines

14 // Connect is the Connection Object

15 Connect Connection

16 //conn.SetMaxOpenConns int = 0

17 //conn.SetMaxIdleConns int = -1

18 )

19

20 func init() {

21 Connect.SetMaxOpenConns = 0

22 Connect.SetMaxIdleConns = -1

23 }

152 // 开始驱动

153 DB, err = sql.Open(driver, dsn)

154 DB.SetMaxOpenConns(conn.SetMaxOpenConns)

155 DB.SetMaxIdleConns(conn.SetMaxIdleConns)

156

mauth.go (https://gitlab.com/mikattack/mauth) Go · 96 lines

6

7 "github.com/spf13/cobra"

8 _ "github.com/mattn/go-sqlite3"

9 "github.com/jmoiron/sqlx"

10

14

15 const (

16 sqlite_default_file string = "./mauth.db"

17 sqlite_default_idle_connections int = 10

54 // NOTE: Persistent flags are not evaluated until the eventual command is

55 // actually run. Until then, the value is the default.

56 MauthCmd.PersistentFlags().StringVar(&dbpath, "db", sqlite_default_file, "Path to SQLite database file")

57 }

58

92 pool.SetMaxIdleConns(sqlite_default_idle_connections)

93 pool.SetMaxOpenConns(sqlite_default_open_connections)

94

95 return pool, nil

gorm.go (https://github.com/NyaaPantsu/nyaa.git) Go · 114 lines

6 "github.com/jinzhu/gorm"

7 _ "github.com/jinzhu/gorm/dialects/postgres" // Need for postgres support

8 _ "github.com/jinzhu/gorm/dialects/sqlite" // Need for sqlite

9 elastic "gopkg.in/olivere/elastic.v5"

10 )

11

12 const (

13 // SqliteType : name of the sqlite type in gorm

14 SqliteType = "sqlite3"

29 var ElasticSearchClient *elastic.Client

30

31 // IsSqlite : Variable to know if we are in sqlite or postgres

32 var IsSqlite bool

52 }

53

54 IsSqlite = conf.DBType == SqliteType

55

56 connectionErr := db.DB().Ping()

sqlite.go (https://github.com/sj14/dbbench.git) Go · 105 lines

10 )

11

12 // SQLite implements the bencher interface.

13 type SQLite struct {

20 )

21

22 // NewSQLite retruns a new SQLite bencher.

23 func NewSQLite(path string) *SQLite {

30

31 // Automatically creates the DB file if it doesn't exist yet.

32 db, err := sql.Open("sqlite3", fmt.Sprintf("%s?cache=shared", path))

33 if err != nil {

34 log.Fatalf("failed to open connection: %v\n", err)

35 }

36

37 db.SetMaxOpenConns(1)

38 p := &SQLite{db: db}

db.go (https://github.com/markphelps/flipt.git) Go · 174 lines

12 "github.com/luna-duclos/instrumentedsql/opentracing"

13 "github.com/markphelps/flipt/config"

14 "github.com/mattn/go-sqlite3"

15 "github.com/xo/dburl"

16 )

50 case SQLite:

51 dr = &sqlite3.SQLiteDriver{}

52 case Postgres:

53 dr = &pq.Driver{}

79 var (

80 driverToString = map[Driver]string{

81 SQLite: "sqlite3",

82 Postgres: "postgres",

83 MySQL: "mysql",

85

86 stringToDriver = map[string]Driver{

87 "sqlite3": SQLite,

88 "postgres": Postgres,

89 "mysql": MySQL,

connection_test.go (https://github.com/knocknote/octillery.git) Go · 486 lines

30

31 func (t *TestAdapter) OpenConnection(config *config.DatabaseConfig, queryValues string) (*sql.DB, error) {

32 return sql.Open("sqlite3", "")

33 }

34

130

131 func init() {

132 adapter.Register("sqlite3", &TestAdapter{})

133 sql.Register("sqlite3", &TestDriver{})

193 defer mgr.Close()

194 mgr.SetMaxIdleConns(10)

195 mgr.SetMaxOpenConns(10)

196 mgr.SetConnMaxLifetime(10 * time.Second)

197 }

app.go (https://github.com/offen/offen.git) Go · 97 lines

14 "gorm.io/driver/mysql"

15 "gorm.io/driver/postgres"

16 "gorm.io/driver/sqlite"

17 "gorm.io/gorm"

18 "gorm.io/gorm/logger"

53 var d gorm.Dialector

54 switch c.Database.Dialect.String() {

55 case "sqlite3":

56 d = sqlite.Open(c.Database.ConnectionString.String())

72 gormDB, err = gorm.Open(d, &gorm.Config{

73 Logger: logger.Default.LogMode(logLevel),

74 DisableForeignKeyConstraintWhenMigrating: c.Database.Dialect.String() == "sqlite3",

75 })

76 return err

87 }

88

89 if c.Database.Dialect == "sqlite3" {

90 db, err := gormDB.DB()

91 if err != nil {

sql.go (https://github.com/haifenghuang/magpie.git) Go · 755 lines

4 "database/sql"

5 _ "fmt"

6 // _ "github.com/mattn/go-sqlite3"

7 _ "reflect"

8 )

73 case "close":

74 return s.Close(line, args...)

75 case "setMaxOpenConns":

76 return s.SetMaxOpenConns(line, args...)

117 }

118

119 func (s *SqlObject) SetMaxOpenConns(line string, args ...Object) Object {

120 if len(args) != 1 {

121 return NewError(line, ARGUMENTERROR, "0", len(args))

124 n, ok := args[0].(*Integer)

125 if !ok {

126 return NewError(line, PARAMTYPEERROR, "first", "setMaxOpenConns", "*Integer", args[0].Type())

127 }

128

db.go (https://github.com/jollheef/out-of-tree.git) Go · 335 lines

11 "time"

12

13 _ "github.com/mattn/go-sqlite3"

14

15 "code.dumpstack.io/tools/out-of-tree/config"

288

289 func openDatabase(path string) (db *sql.DB, err error) {

290 db, err = sql.Open("sqlite3", path)

291 if err != nil {

292 return

293 }

294

295 db.SetMaxOpenConns(1)

296

297 exists, _ := metaChkValue(db, versionField)

connection.go (https://github.com/arschles/go-in-5-minutes.git) Go · 189 lines

55 case "mysql":

56 c.Dialect = newMySQL(deets)

57 case "sqlite3":

58 c.Dialect, err = newSQLite(deets)

91 }

92 db, err := sqlx.Open(c.Dialect.Details().Dialect, c.Dialect.URL())

93 db.SetMaxOpenConns(c.Dialect.Details().Pool)

94 if err == nil {

95 c.Store = &dB{db}

maxconnect.go (https://github.com/codetainerapp/codetainer.git) Go · 107 lines

8 _ "github.com/go-sql-driver/mysql"

9 "github.com/go-xorm/xorm"

10 _ "github.com/mattn/go-sqlite3"

11 )

12

16 }

17

18 func sqliteEngine() (*xorm.Engine, error) {

19 os.Remove("./test.db")

20 return xorm.NewEngine("sqlite3", "./goroutine.db")

35

36 engine.ShowSQL = true

37 engine.SetMaxOpenConns(5)

38

39 size := 1000

sqlite3.go (https://github.com/lighttiger2505/sqls.git) Go · 144 lines

13 RegisterOpen("sqlite3", sqlite3Open)

14 RegisterFactory("sqlite3", NewSQLite3DBRepository)

15 }

16

17 func sqlite3Open(connCfg *DBConfig) (*DBConnection, error) {

18 conn, err := sql.Open("sqlite3", connCfg.DataSourceName)

21 }

22 conn.SetMaxIdleConns(DefaultMaxIdleConns)

23 conn.SetMaxOpenConns(DefaultMaxOpenConns)

24 return &DBConnection{

25 Conn: conn,

39 }

40

41 func (db *SQLite3DBRepository) Databases(ctx context.Context) ([]string, error) {

42 return []string{}, nil

43 }

database.go (https://github.com/uber/kraken.git) Go · 46 lines

21

22 "github.com/jmoiron/sqlx"

23 _ "github.com/mattn/go-sqlite3" // SQL driver.

24 "github.com/pressly/goose"

25 )

26

27 // New creates a new locally embedded SQLite database.

28 func New(config Config) (*sqlx.DB, error) {

29 if err := osutil.EnsureFilePresent(config.Source, 0775); err != nil {

30 return nil, fmt.Errorf("ensure db source present: %s", err)

31 }

32 db, err := sqlx.Open("sqlite3", config.Source)

33 if err != nil {

34 return nil, fmt.Errorf("open sqlite3: %s", err)

sqlite.go (https://github.com/status-im/status-go.git) Go · 88 lines

1 package sqlite

2

3 import (

15 // https://notes.status.im/i8Y_l7ccTiOYq09HVgoFwA

16 kdfIterationsNumber = 3200

17 // WALMode for sqlite.

18 WALMode = "wal"

19 )

20

21 func openDB(path, key string) (*sql.DB, error) {

22 db, err := sql.Open("sqlite3", path)

23 if err != nil {

24 return nil, err

26

27 // Disable concurrent access as not supported by the driver

28 db.SetMaxOpenConns(1)

29

30 if _, err = db.Exec("PRAGMA foreign_keys=ON"); err != nil {

data.go (https://github.com/gabek/owncast.git) Go · 135 lines

46 }

47

48 db, err := sql.Open("sqlite3", fmt.Sprintf("file:%s?_cache_size=10000&cache=shared&_journal_mode=WAL", file))

49 db.SetMaxOpenConns(1)

50 _db = db

51

52 // Some SQLite optimizations

53 _, _ = db.Exec("pragma journal_mode = WAL")

54 _, _ = db.Exec("pragma synchronous = normal")

orm.go (https://github.com/KyleBanks/goggles.git) Go · 135 lines

10 _ "github.com/go-sql-driver/mysql"

11 "github.com/jinzhu/gorm"

12 // Required to initialize the sqlite driver.

13 _ "github.com/jinzhu/gorm/dialects/sqlite"

46 db.LogMode(true)

47 db.DB().SetMaxIdleConns(10)

48 db.DB().SetMaxOpenConns(0) // Unlimited

49

50 orm.conn = db

db_test.go (https://github.com/storj/storj.git) Go · 67 lines

8

9 _ "github.com/jackc/pgx/v4/stdlib"

10 _ "github.com/mattn/go-sqlite3"

11 "github.com/stretchr/testify/require"

12

21 t.Helper()

22

23 t.Run("mattn-sqlite3", func(t *testing.T) {

24 ctx := testcontext.New(t)

25 defer ctx.Cleanup()

26

27 db, err := tagsql.Open("sqlite3", ":memory:")

28 if err != nil {

29 t.Fatal(err)

sqlite.go (https://github.com/fnproject/fn.git) Go · 73 lines

16 func (sqliteHelper) Supports(scheme string) bool {

17 switch scheme {

18 case "sqlite3", "sqlite":

19 return true

20 }

38 }

39

40 func (sqliteHelper) CheckTableExists(tx *sqlx.Tx, table string) (bool, error) {

41 query := tx.Rebind(`SELECT count(*)

42 FROM sqlite_master

62 sqliteErr, ok := err.(sqlite3.Error)

63 if ok {

64 if sqliteErr.ExtendedCode == sqlite3.ErrConstraintUnique || sqliteErr.ExtendedCode == sqlite3.ErrConstraintPrimaryKey {

65 return true

66 }

db.go (https://github.com/drone/autoscaler.git) Go · 70 lines

28 case "mysql":

29 db.SetMaxIdleConns(0)

30 case "sqlite3":

31 db.SetMaxOpenConns(1)

db.go (https://github.com/status-im/status-go.git) Go · 159 lines

1 package sqlite

2

3 import (

40 }

41

42 // OpenInMemory opens an in memory SQLite database.

43 // Number of KDF iterations is reduced to 0.

44 func OpenInMemory() (*sql.DB, error) {

60 }

61

62 db, err := sql.Open("sqlite3", path)

63 if err != nil {

64 return nil, err

68

69 // Disable concurrent access as not supported by the driver

70 db.SetMaxOpenConns(1)

71

72 if _, err = db.Exec("PRAGMA foreign_keys=ON"); err != nil {

connection.go (https://github.com/hunterlong/statping.git) Go · 107 lines

35 }

36

37 // Connect will attempt to connect to the sqlite, postgres, or mysql database

38 func Connect(configs *DbConfig, retry bool) error {

39 conn := configs.ConnectionString()

58

59 db := dbSession.DB()

60 db.SetMaxOpenConns(utils.Params.GetInt("MAX_OPEN_CONN"))

61 db.SetMaxIdleConns(utils.Params.GetInt("MAX_IDLE_CONN"))

62 db.SetConnMaxLifetime(utils.Params.GetDuration("MAX_LIFE_CONN"))

db.go (https://github.com/sentriz/gonic.git) Go · 155 lines

36 return url.Values{

37 // with this, multiple connections share a single data and schema cache.

38 // see https://www.sqlite.org/sharedcache.html

39 "cache": {"shared"},

40 // with this, the db sleeps for a little while when locked. can prevent

41 // a SQLITE_BUSY. see https://www.sqlite.org/c3ref/busy_timeout.html

42 "_busy_timeout": {"30000"},

43 "_journal_mode": {"WAL"},

51

52 func New(path string) (*DB, error) {

53 // https://github.com/mattn/go-sqlite3#connection-string

54 url := url.URL{

55 Scheme: "file",

init.go (https://github.com/bullteam/zeus-admin.git) Go · 70 lines

6 "github.com/jinzhu/gorm"

7 _ "github.com/jinzhu/gorm/dialects/mysql"

8 _ "github.com/jinzhu/gorm/dialects/sqlite"

9 "github.com/spf13/viper"

10 "zeus/pkg/api/domain/search/adapter/statement"

18 const (

19 DRIVER_MYSQL = "mysql"

20 DRIVER_SQLITE = "sqlite"

21 )

22

29 case DRIVER_SQLITE:

30 db, err = gorm.Open("sqlite3", viper.GetString("database.sqlite.dsn"))

31 if err != nil {

32 log.Fatal(fmt.Sprintf("Failed to connect sqlite %s", err.Error()))

48 } else {

49 db.DB().SetMaxIdleConns(viper.GetInt("database.mysql.pool.min"))

50 db.DB().SetMaxOpenConns(viper.GetInt("database.mysql.pool.max"))

51 if gin.Mode() != gin.ReleaseMode {

52 db.LogMode(true)

db_alias.go (https://gitlab.com/chenggangschool/beego.git) Go · 278 lines

15 _ DriverType = iota // int enum type

16 DR_MySQL // mysql

17 DR_Sqlite // sqlite

18 DR_Oracle // oracle

19 DR_Postgres // pgsql

42 "mysql": DR_MySQL,

43 "postgres": DR_Postgres,

44 "sqlite3": DR_Sqlite,

45 }

46 dbBasers = map[DriverType]dbBaser{

47 DR_MySQL: newdbBaseMysql(),

48 DR_Sqlite: newdbBaseSqlite(),

49 DR_Oracle: newdbBaseMysql(),

50 DR_Postgres: newdbBasePostgres(),

sys_db.go (https://github.com/micro-plat/hydra.git) Go · 181 lines

8 "time"

9 //_ "github.com/mattn/go-oci8"

10 //_ "github.com/mattn/go-sqlite3"

11 //_ "gopkg.in/rana/ora.v4"

12 )

34

35 const (

36 //SQLITE3 Sqlite3数据库

37 SQLITE3 = "sqlite3"

78 case "ora", "oracle":

79 obj.db, err = sql.Open(OCI8, connString)

80 case "sqlite":

81 obj.db, err = sql.Open(SQLITE3, connString)

87 }

88 obj.db.SetMaxIdleConns(maxIdle)

89 obj.db.SetMaxOpenConns(maxOpen)

90 obj.db.SetConnMaxLifetime(maxLifeTime)

91 err = obj.db.Ping()

main.go (https://github.com/go-reform/reform.git) Go · 152 lines

15 _ "github.com/jackc/pgx/stdlib"

16 _ "github.com/lib/pq"

17 _ "github.com/mattn/go-sqlite3"

18

19 "gopkg.in/reform.v1"

57

58 // Use single connection so various session-related variables work.

59 // For example: "PRAGMA foreign_keys" for SQLite3, "SET IDENTITY_INSERT" for MS SQL, etc.

60 sqlDB.SetMaxIdleConns(1)

61 sqlDB.SetMaxOpenConns(1)

root.go (https://github.com/stephenafamo/docker-nginx-auto-proxy.git) Go · 98 lines

47

48 log.Println("Connecting to DB...")

49 db, err := sql.Open("sqlite3", "file::memory:?_fk=1&cache=shared&mode=memory")

50 if err != nil {

51 return err

52 }

53 db.SetMaxOpenConns(1)

54 defer db.Close()

55

db.go (https://github.com/photoprism/photoprism.git) Go · 113 lines

8 "github.com/jinzhu/gorm"

9 _ "github.com/jinzhu/gorm/dialects/mysql"

10 _ "github.com/jinzhu/gorm/dialects/sqlite"

11 )

12

14 const (

15 MySQL = "mysql"

16 SQLite = "sqlite3"

17 )

18

97 db.SetLogger(log)

98 db.DB().SetMaxIdleConns(4)

99 db.DB().SetMaxOpenConns(256)

100

101 g.db = db

dao.go (https://github.com/zendea/zendea.git) Go · 99 lines

8 "github.com/jinzhu/gorm"

9 _ "github.com/jinzhu/gorm/dialects/mysql"

10 _ "github.com/jinzhu/gorm/dialects/sqlite"

11 "github.com/spf13/viper"

12

20

21 const DRIVER_MYSQL = "mysql"

22 const DRIVER_SQLITE = "sqlite"

23

24 // Setup : Connect to mysql database

27

28 switch viper.Get("database.driver") {

29 case DRIVER_SQLITE:

30 path := viper.GetString("database.sqlite.path")

31 db, err = gorm.Open("sqlite3", path)

32 if err != nil {

33 log.Fatal(fmt.Sprintf("Failed to connect sqlite %s", err.Error()))

conf.go (https://github.com/zer0131/RedisFox.git) Go · 117 lines

4 "github.com/go-yaml/yaml"

5 "github.com/jinzhu/gorm"

6 _ "github.com/jinzhu/gorm/dialects/sqlite"

7 "io/ioutil"

8 "time"

55 return err

56 }

57 db.DB().SetMaxOpenConns(autoBaseVal.Datamaxopenconn)

58 db.DB().SetMaxIdleConns(autoBaseVal.Datamaxidleconn)

59 liftTime := time.Duration(autoBaseVal.Datamaxconnlifetime) * time.Millisecond

database.go (https://github.com/bojand/ghz.git) Go · 71 lines

10 _ "github.com/jinzhu/gorm/dialects/mysql" // enable the mysql dialect

11 _ "github.com/jinzhu/gorm/dialects/postgres" // enable the postgres dialect

12 _ "github.com/jinzhu/gorm/dialects/sqlite" // enable the sqlite3 dialect

13 )

14

17 // New creates a new wrapper for the gorm database framework.

18 func New(dialect, connection string, log bool) (*Database, error) {

19 if err := createDirectoryIfSqlite(dialect, connection); err != nil {

20 return nil, err

21 }

29

30 // We normally don't need that much connections, so we limit them.

31 db.DB().SetMaxOpenConns(10)

32

33 if dialect == "sqlite3" {

db.go (https://github.com/labulaka521/crocodile.git) Go · 92 lines

6 "time"

7

8 _ "github.com/go-sql-driver/mysql" // registry sqlite3 deive

9 _ "github.com/mattn/go-sqlite3" // registry mysql drive

30 type Option func(*dbCfg)

31

32 // Drivename Set mysql or sqlite

33 func Drivename(drivename string) Option {

34 return func(dbcfg *dbCfg) {

67 func defaultdbOption() *dbCfg {

68 return &dbCfg{

69 DriveName: "sqlite3",

70 Dsn: "sqlite3.db",

86 return err

87 }

88 _db.SetMaxOpenConns(dbcfg.MaxOpenConnection)

89 _db.SetMaxIdleConns(dbcfg.MaxIdleConnection)

90 err = _db.Ping()

base_db.go (https://github.com/netsec-ethz/scion.git) Go · 85 lines

13 // limitations under the License.

14

15 package drkeydbsqlite

16

17 import (

18 "database/sql"

19

20 _ "github.com/mattn/go-sqlite3"

21

22 "github.com/scionproto/scion/go/lib/drkey"

39 // newBaseBackend builds the base backend common for all level backends.

40 func newBaseBackend(path, schema string, version int) (*dbBaseBackend, error) {

41 db, err := db.NewSqlite(path, schema, version)

42 if err != nil {

43 return nil, err

sqlite.go (https://github.com/status-im/status-go.git) Go · 124 lines

52 }

53

54 db, err := sql.Open("sqlite3", path)

55 if err != nil {

56 return nil, err

60

61 // Disable concurrent access as not supported by the driver

62 db.SetMaxOpenConns(1)

63

64 if _, err = db.Exec("PRAGMA foreign_keys=ON"); err != nil {

engine_group_test.go (https://github.com/xormplus/xorm.git) Go · 35 lines

19

20 main := testEngine.(*xorm.Engine)

21 if main.Dialect().URI().DBType == schemas.SQLITE {

22 t.Skip()

23 return

28

29 eg.SetMaxIdleConns(10)

30 eg.SetMaxOpenConns(100)

31 eg.SetTableMapper(main.GetTableMapper())

32 eg.SetColumnMapper(main.GetColumnMapper())

ToolsModel.go (https://github.com/3xxx/engineercms.git) Go · 94 lines

7 // "github.com/astaxie/beego"

8 // "github.com/jinzhu/gorm"

9 // // _ "github.com/jinzhu/gorm/dialects/sqlite"

10 // )

11

62 // _db.LogMode(true)

63 // //设置数据库连接池参数

64 // _db.DB().SetMaxOpenConns(100) //设置数据库连接池最大连接数

65 // _db.DB().SetMaxIdleConns(20) //连接池最大允许的空闲连接数,如果没有sql任务需要执行的连接数大于20,超过的连接会被连接池关闭。

66 // }

dbUtil.go (https://github.com/hacklcx/HFish.git) Go · 38 lines

3 import (

4 _ "github.com/go-sql-driver/mysql"

5 _ "github.com/mattn/go-sqlite3"

6 "HFish/utils/conf"

7 "HFish/utils/log"

21 if dbType == "sqlite" {

22 engin, err = gorose.Open(&gorose.Config{Driver: "sqlite3", Dsn: dbStr, SetMaxOpenConns: dbMaxOpen, SetMaxIdleConns: dbMaxIdle})

23

24 if err != nil {

25 log.Pr("HFish", "127.0.0.1", "连接 Sqlite 数据库失败", err)

26 }

27 } else if dbType == "mysql" {

28 engin, err = gorose.Open(&gorose.Config{Driver: "mysql", Dsn: dbStr, SetMaxOpenConns: dbMaxOpen, SetMaxIdleConns: dbMaxIdle})

29

30 if err != nil {

database_connection.go (https://github.com/daptin/daptin.git) Go · 52 lines

5 "github.com/jmoiron/sqlx"

6 _ "github.com/lib/pq"

7 _ "github.com/mattn/go-sqlite3"

8 "strings"

9 "time"

35 }

36 db.SetMaxIdleConns(2)

37 db.SetMaxOpenConns(50)

38 db.SetConnMaxLifetime(20 * time.Second)

39 return db, e

base.go (https://github.com/it234/goapp.git) Go · 45 lines

19 if config.Gorm.DBType=="mysql"{

20 config.Gorm.DSN=config.MySQL.DSN()

21 } else if config.Gorm.DBType=="sqlite3"{

22 config.Gorm.DSN=config.Sqlite3.DSN()

32 }

33 gdb.DB().SetMaxIdleConns(config.Gorm.MaxIdleConns)

34 gdb.DB().SetMaxOpenConns(config.Gorm.MaxOpenConns)

35 gdb.DB().SetConnMaxLifetime(time.Duration(config.Gorm.MaxLifetime) * time.Second)

36 db.DB=gdb

sqlite.go (https://bitbucket.org/depechebot/pyjamabot.git) Go · 289 lines

1 package sqlite

2

3 import (

29

30 // slowing this model down cause of this bug:

31 // https://github.com/mattn/go-sqlite3/issues/274

32 m.db.SetMaxOpenConns(1)

open.go (https://github.com/facebookincubator/magma.git) Go · 46 lines

20 _ "github.com/go-sql-driver/mysql"

21 _ "github.com/lib/pq"

22 _ "github.com/mattn/go-sqlite3"

23 )

24

26 MariaDriver = "mysql"

27 PostgresDriver = "postgres"

28 SQLiteDriver = "sqlite3"

29 )

30

31 // Open is a wrapper for sql.Open which sets the max open connections to 1

32 // for in memory sqlite3 dbs. In memory sqlite3 creates a new database

33 // on each connection, so the number of open connections must be limited

34 // to 1 for thread safety. Otherwise, there is a race condition between

sqlitePieceCompletion.go (https://github.com/yunionio/onecloud.git) Go · 55 lines

8

9 "github.com/anacrolix/torrent/metainfo"

10 _ "github.com/mattn/go-sqlite3"

11 )

12

13 type sqlitePieceCompletion struct {

14 db *sql.DB

15 }

17 var _ PieceCompletion = (*sqlitePieceCompletion)(nil)

18

19 func NewSqlitePieceCompletion(dir string) (ret *sqlitePieceCompletion, err error) {

20 p := filepath.Join(dir, ".torrent.db")

21 db, err := sql.Open("sqlite3", p)

sql.go (https://github.com/keel-hq/keel.git) Go · 84 lines

9 "github.com/keel-hq/keel/types"

10

11 // importing sqlite driver

12 _ "github.com/jinzhu/gorm/dialects/sqlite"

20

21 type Opts struct {

22 DatabaseType string // sqlite3 / postgres

23 URI string // path or conn string

24 }

75 }

76

77 db.DB().SetMaxOpenConns(40)

78

79 // success

db.go (https://github.com/iwannay/jiacrontab.git) Go · 93 lines

20 func CreateDB(dialect string, args ...interface{}) error {

21 switch dialect {

22 case "sqlite3":

23 return createSqlite3(dialect, args...)

30 }

31

32 func createSqlite3(dialect string, args ...interface{}) error {

33 var err error

34 if args[0] == nil {

35 return errors.New("sqlite3:db file cannot empty")

36 }

37

39 err = os.MkdirAll(dbDir, 0755)

40 if err != nil {

41 return fmt.Errorf("sqlite3:%s", err)

42 }

43

init.go (https://github.com/cloudreve/Cloudreve.git) Go · 80 lines

11

12 _ "github.com/jinzhu/gorm/dialects/mysql"

13 _ "github.com/jinzhu/gorm/dialects/sqlite"

14 )

15

28 if gin.Mode() == gin.TestMode {

29 // 测试模式下,使用内存数据库

30 db, err = gorm.Open("sqlite3", ":memory:")

31 } else {

32 switch conf.DatabaseConfig.Type {

33 case "UNSET", "sqlite", "sqlite3":

34 // 未指定数据库或者明确指定为 sqlite 时,使用 SQLite3 数据库

35 db, err = gorm.Open("sqlite3", util.RelativePath(conf.DatabaseConfig.DBFile))

sql_connector.go (https://github.com/kyawmyintthein/golangRestfulAPISample.git) Go · 108 lines

9 "github.com/kyawmyintthein/orange-contrib/logx"

10 _ "github.com/lib/pq"

11 _ "github.com/mattn/go-sqlite3"

12 )

13

17 Mysql DBDriver = `mysql`

18 Postgres DBDriver = `postgres`

19 Sqlite3 DBDriver = `sqlite3`

20 )

21

54 connectionString = getPostgresConnectionString(cfg)

55 break

56 case Sqlite3:

57 return nil, fmt.Errorf("connection string is empty! Use URI to set sqlite DB")

76

77 db.SetMaxIdleConns(cfg.MaxIdleConns)

78 db.SetMaxOpenConns(cfg.MaxOpenConns)

79 db.SetConnMaxLifetime(cfg.ConnMaxLifetime * time.Second)

80 err = db.Ping()

database.go (https://github.com/snowlyg/IrisApiProject.git) Go · 45 lines

9 _ "github.com/jinzhu/gorm/dialects/mysql"

10 _ "github.com/jinzhu/gorm/dialects/postgres"

11 _ "github.com/jinzhu/gorm/dialects/sqlite"

12 "github.com/snowlyg/IrisAdminApi/config"

13 "github.com/snowlyg/IrisAdminApi/libs"

26 } else if config.Config.DB.Adapter == "postgres" {

27 conn = fmt.Sprintf("postgres://%v:%v@%v/%v?sslmode=disable", config.Config.DB.User, config.Config.DB.Password, config.Config.DB.Host, config.Config.DB.Name)

28 } else if config.Config.DB.Adapter == "sqlite3" {

29 conn = libs.DBFile()

30 } else {

42

43 Db.DB().SetMaxIdleConns(10)

44 Db.DB().SetMaxOpenConns(100)

45 }

46

gorm.go (https://github.com/LyricTian/gin-admin.git) Go · 79 lines

13 _ "github.com/jinzhu/gorm/dialects/mysql"

14 _ "github.com/jinzhu/gorm/dialects/postgres"

15 _ "github.com/jinzhu/gorm/dialects/sqlite"

16 )

17

56 db.SingularTable(true)

57 db.DB().SetMaxIdleConns(c.MaxIdleConns)

58 db.DB().SetMaxOpenConns(c.MaxOpenConns)

59 db.DB().SetConnMaxLifetime(time.Duration(c.MaxLifetime) * time.Second)

60 return db, cleanFunc, nil

sqlite.go (https://github.com/netsec-ethz/scion.git) Go · 122 lines

23 )

24

25 // NewSqlite returns a new SQLite backend opening a database at the given path. If

26 // no database exists a new database is be created. If the schema version of the

27 // stored database is different from schemaVersion, an error is returned.

28 func NewSqlite(path string, schema string, schemaVersion int) (*sql.DB, error) {

29 var err error

30 if path == "" {

31 return nil, serrors.New("Empty path not allowed for sqlite")

32 }

33 db, err := open(path)

models.go (https://github.com/CovenantSQL/CovenantSQL.git) Go · 53 lines

5 "fmt"

6

7 _ "github.com/CovenantSQL/go-sqlite3-encrypt" // sqlite3 driver

8 "github.com/go-gorp/gorp"

9 "github.com/pkg/errors"

19 }

20

21 // OpenSQLiteDBAsGorp opens a sqlite database an wrapped it in gorp.DbMap.

22 func OpenSQLiteDBAsGorp(dbFile, mode string, maxOpen, maxIdle int) (db *gorp.DbMap, err error) {

23 dsn := fmt.Sprintf("%s?_journal=WAL&mode=%s", dbFile, mode)

24 underdb, err := sql.Open("sqlite3", dsn)

25 if err != nil {

26 return nil, errors.Wrapf(err, "unable to open database %q", dsn)

27 }

28 underdb.SetMaxOpenConns(maxOpen)

29 underdb.SetMaxIdleConns(maxIdle)

30

sqlite.go (https://github.com/EasyDarwin/EasyDarwin.git) Go · 44 lines

6

7 "github.com/jinzhu/gorm"

8 _ "github.com/jinzhu/gorm/dialects/sqlite"

9 "github.com/penggy/EasyGoLib/utils"

10 )

25 dbFile := utils.DBFile()

26 log.Println("db file -->", utils.DBFile())

27 SQLite, err = gorm.Open("sqlite3", fmt.Sprintf("%s?loc=Asia/Shanghai", dbFile))

28 if err != nil {

29 return

30 }

31 // Sqlite cannot handle concurrent writes, so we limit sqlite to one connection.

32 // see https://github.com/mattn/go-sqlite3/issues/274

33 SQLite.DB().SetMaxOpenConns(1)

34 SQLite.SetLogger(DefaultGormLogger)

database.go (https://github.com/yuchenyang1994/docker-doge.git) Go · 67 lines

10 "github.com/gin-gonic/gin"

11 "github.com/jinzhu/gorm"

12 _ "github.com/jinzhu/gorm/dialects/sqlite"

13 )

14

28 db, err = gorm.Open(conf.DATABASE_BACKEND, conf.DATABASE_URI)

29 db.DB().SetMaxIdleConns(10)

30 db.DB().SetMaxOpenConns(100)

31 if err != nil {

32 log.Fatal("db error")

37

38 func GetTestDB() *gorm.DB {

39 db, err := gorm.Open("sqlite3", "/tmp/test.db")

40 if err != nil {

41 log.Fatal("db error")

config.go (https://github.com/gohouse/gorose.git) Go · 20 lines

3 // Config ...

4 type Config struct {

5 Driver string `json:"driver"` // 驱动: mysql/sqlite3/oracle/mssql/postgres/clickhouse, 如果集群配置了驱动, 这里可以省略

6 // mysql 示例:

7 // root:root@tcp(localhost:3306)/test?charset=utf8mb4&parseTime=true

8 Dsn string `json:"dsn"` // 数据库链接

9 SetMaxOpenConns int `json:"setMaxOpenConns"` // (连接池)最大打开的连接数,默认值为0表示不限制

10 SetMaxIdleConns int `json:"setMaxIdleConns"` // (连接池)闲置的连接数, 默认0

11 Prefix string `json:"prefix"` // 表前缀, 如果集群配置了前缀, 这里可以省略

sqlite3.go (https://github.com/thrasher-/gocryptotrader.git) Go · 29 lines

1 package sqlite

2

3 import (

5 "path/filepath"

6

7 // import sqlite3 driver

8 _ "github.com/mattn/go-sqlite3"

10 )

11

12 // Connect opens a connection to sqlite database and returns a pointer to database.DB

13 func Connect() (*database.Instance, error) {

14 if database.DB.Config.Database == "" {

18 databaseFullLocation := filepath.Join(database.DB.DataPath, database.DB.Config.Database)

19

20 dbConn, err := sql.Open("sqlite3", databaseFullLocation)

21 if err != nil {

22 return nil, err

mssql.go (https://github.com/Azareal/Gosora.git) Go · 97 lines

49

50 // Set the number of max open connections

51 db.SetMaxOpenConns(64)

52 db.SetMaxIdleConns(32)

53

56 db.SetConnMaxLifetime(c.DBTimeout())

57

58 // Build the generated prepared statements, we are going to slowly move the queries over to the query generator rather than writing them all by hand, this'll make it easier for us to implement database adapters for other databases like PostgreSQL, MSSQL, SQlite, etc.

59 err = _gen_mssql()

60 if err != nil {

sqlite.go (https://github.com/Dentrax/GMDB.git) Go · 61 lines

16

17 "github.com/jmoiron/sqlx"

18 _ "github.com/mattn/go-sqlite3"

19 )

20

34 }

35

36 db.SetMaxOpenConns(1)

37

38 var engine Driver = Sqlite

gorm.go (https://github.com/gitDashboard/gitDashboard.git) Go · 146 lines

6 _ "github.com/go-sql-driver/mysql"

7 "github.com/jinzhu/gorm"

8 _ "github.com/jinzhu/gorm/dialects/sqlite"

9 _ "github.com/lib/pq"

10 "github.com/revel/revel"

48 Db.DB().Ping()

49 Db.DB().SetMaxIdleConns(10)

50 Db.DB().SetMaxOpenConns(100)

51

52 perm := &models.Permission{}

models.go (https://github.com/duo-labs/webauthn.io.git) Go · 89 lines

15 _ "github.com/go-sql-driver/mysql" // Blank import needed to import mysql

16 "github.com/jinzhu/gorm"

17 _ "github.com/mattn/go-sqlite3" // Blank import needed to import sqlite3

18 )

19

54 db.LogMode(false)

55 db.SetLogger(log.Logger)

56 db.DB().SetMaxOpenConns(1)

57 if err != nil {

58 return err

service.go (https://github.com/henrylee2cn/faygo.git) Go · 114 lines

13 _ "github.com/lib/pq" //postgres

14 // _ "github.com/mattn/go-oci8" //oracle(need to install the pkg-config utility)

15 // _ "github.com/mattn/go-sqlite3" //sqlite

16

17 "github.com/henrylee2cn/faygo"

61 }

62 engine.SetLogger(iLogger)

63 engine.SetMaxOpenConns(conf.MaxOpenConns)

64 engine.SetMaxIdleConns(conf.MaxIdleConns)

65 engine.SetDisableGlobalCache(conf.DisableCache)

95 }

96

97 if conf.Driver == "sqlite3" && !faygo.FileExists(conf.Connstring) {

98 os.MkdirAll(filepath.Dir(conf.Connstring), 0777)

99 f, err := os.Create(conf.Connstring)

sql_init.go (https://github.com/fnproject/flow.git) Go · 120 lines

16

17 var tables = map[string][]string{

18 "sqlite3": {

19 `CREATE TABLE IF NOT EXISTS events (

20 actor_name varchar(255) NOT NULL,

63 driver := url.Scheme

64 switch driver {

65 case "mysql", "sqlite3":

66 default:

67

69 }

70

71 if driver == "sqlite3" {

72 dir := filepath.Dir(url.Path)

73 err := os.MkdirAll(dir, 0755)

cmdutils.go (https://github.com/dude333/rapina.git) Go · 118 lines

36 }

37 connStr := "file:" + dataDir + "/rapina.db?cache=shared&mode=rwc&_journal_mode=WAL&_busy_timeout=5000"

38 db, err = sql.Open("sqlite3", connStr)

39 if err != nil {

40 return db, errors.Wrap(err, "database open failed")

41 }

42 db.SetMaxOpenConns(1)

43

44 return

conn.go (https://github.com/eolinker/goku-api-gateway.git) Go · 64 lines

10 //mysql数据库驱动

11 _ "github.com/go-sql-driver/mysql"

12 //sqlite3数据库驱动

13 _ "github.com/mattn/go-sqlite3"

31 return nil, err

32 }

33 db.SetMaxOpenConns(1000)

34 db.SetMaxIdleConns(100)

35 defaultDB = db

service.go (https://github.com/henrylee2cn/faygo.git) Go · 78 lines

11 _ "github.com/jinzhu/gorm/dialects/mysql" //github.com/go-sql-driver/mysql

12 _ "github.com/jinzhu/gorm/dialects/postgres" //github.com/lib/pq

13 // _ "github.com/jinzhu/gorm/dialects/sqlite" //github.com/mattn/go-sqlite3

14

15 "github.com/henrylee2cn/faygo"

56 engine.LogMode(conf.ShowSql)

57

58 engine.DB().SetMaxOpenConns(conf.MaxOpenConns)

59 engine.DB().SetMaxIdleConns(conf.MaxIdleConns)

60

61 if conf.Driver == "sqlite3" && !faygo.FileExists(conf.Connstring) {

62 os.MkdirAll(filepath.Dir(conf.Connstring), 0777)

63 f, err := os.Create(conf.Connstring)

database.go (https://github.com/xmlking/micro-starter-kit.git) Go · 66 lines

17

18 switch dbConf.Dialect {

19 case configPB.DatabaseDialect_SQLite3:

20 db, err = connection(dbConf)

21 case configPB.DatabaseDialect_Postgre:

44 db.LogMode(dbConf.Logging)

45 db.SingularTable(dbConf.Singularize)

46 db.DB().SetMaxOpenConns(int(dbConf.MaxOpenConns))

47 db.DB().SetMaxIdleConns(int(dbConf.MaxIdleConns))

48 db.DB().SetConnMaxLifetime(*dbConf.ConnMaxLifetime)

db.go (https://github.com/IBM/cloudland.git) Go · 196 lines

24 "github.com/jinzhu/gorm"

25 _ "github.com/jinzhu/gorm/dialects/postgres"

26 _ "github.com/jinzhu/gorm/dialects/sqlite"

27 )

28

46

47 if testMode {

48 dbType = "sqlite3"

49 dbUrl = "file::memory:?cache=shared"

50 }

51 if dbType == "" {

52 dbType = "sqlite3"

53 dbUrl = "cland.db"

54 }

database.go (https://github.com/traggo/server.git) Go · 57 lines

8 _ "github.com/jinzhu/gorm/dialects/mysql" // enable the mysql dialect

9 _ "github.com/jinzhu/gorm/dialects/postgres" // enable the postgres dialect

10 _ "github.com/jinzhu/gorm/dialects/sqlite" // enable the sqlite3 dialect

11 "github.com/rs/zerolog/log"

12 "github.com/traggo/server/logger"

18 // New creates a gorm instance.

19 func New(dialect, connection string) (*gorm.DB, error) {

20 createDirectoryIfSqlite(dialect, connection)

21

22 db, err := gorm.Open(dialect, connection)

29 // We normally don't need that much connections, so we limit them. F.ex. mysql complains about

30 // "too many connections".

31 db.DB().SetMaxOpenConns(10)

32

33 if dialect == "sqlite3" {

connection.go (https://github.com/bigfile/bigfile.git) Go · 60 lines

14 // import mysql database driver

15 _ "github.com/jinzhu/gorm/dialects/mysql"

16 // import sqlite database driver

17 _ "github.com/jinzhu/gorm/dialects/sqlite"

40 }

41 connection.DB().SetConnMaxLifetime(time.Hour)

42 connection.DB().SetMaxOpenConns(500)

43 connection.DB().SetMaxIdleConns(0)

44 }

db.go (https://github.com/LockGit/gochat.git) Go · 57 lines

8 import (

9 "github.com/jinzhu/gorm"

10 _ "github.com/jinzhu/gorm/dialects/sqlite"

11 "github.com/sirupsen/logrus"

12 "gochat/config"

27 // if prod env , you should change mysql driver for yourself !!!

28 realPath, _ := filepath.Abs("./")

29 configFilePath := realPath + "/db/gochat.sqlite3"

30 syncLock.Lock()

31 dbMap[dbName], e = gorm.Open("sqlite3", configFilePath)

32 dbMap[dbName].DB().SetMaxIdleConns(4)

33 dbMap[dbName].DB().SetMaxOpenConns(20)

34 dbMap[dbName].DB().SetConnMaxLifetime(8 * time.Second)

35 if config.GetMode() == "dev" {

database.go (https://github.com/Clivern/Beetle.git) Go · 216 lines

14 "github.com/jinzhu/gorm"

15 _ "github.com/jinzhu/gorm/dialects/mysql"

16 _ "github.com/jinzhu/gorm/dialects/sqlite"

17 log "github.com/sirupsen/logrus"

18 "github.com/spf13/viper"

56

57 // Cleanup stale connections http://go-database-sql.org/surprises.html

58 db.Connection.DB().SetMaxOpenConns(5)

59 db.Connection.DB().SetConnMaxLifetime(time.Duration(10) * time.Second)

60 dbStats := db.Connection.DB().Stats()

db.go (https://github.com/bakape/hydron.git) Go · 83 lines

13 "github.com/bakape/hydron/files"

14 _ "github.com/lib/pq"

15 _ "github.com/mattn/go-sqlite3"

16 )

17

40 }

41 if conf.Driver == "" || conf.Connection == "" {

42 conf.Driver = "sqlite3"

43 // Shared cache is required for multithreading

44 conf.Connection = fmt.Sprintf("file:%s?cache=shared&mode=rwc",

53 sq = squirrel.StatementBuilder.RunWith(squirrel.NewStmtCacheProxy(db))

54 switch conf.Driver {

55 case "sqlite3":

56 // To avoid locking "database locked" errors. Hard limitation of SQLite,

57 // when used from multiple threads.

58 db.SetMaxOpenConns(1)

59 case "postgres":

60 sq = sq.PlaceholderFormat(squirrel.Dollar)

api_sqlite.go (https://github.com/vadv/gopher-lua-libs.git) Go · 79 lines

18

19 func init() {

20 RegisterDriver(`sqlite3`, &luaSQLite{})

21 }

22

54 }

55

56 func (sqlite *luaSQLite) getDB() *sql.DB {

57 sqlite.Lock()

64 }

65

66 func (sqlite *luaSQLite) closeDB() error {

67 sqlite.Lock()

74 sharedSqliteLock.Lock()

75 delete(sharedSqlite, sqlite.config.connString)

76 sharedSqliteLock.Unlock()

model.go (https://github.com/indes/flowerss-bot.git) Go · 64 lines

8

9 _ "github.com/jinzhu/gorm/dialects/mysql" //mysql driver

10 _ "github.com/jinzhu/gorm/dialects/sqlite"

11

12 "moul.io/zapgorm"

26 db, err = gorm.Open("mysql", config.Mysql.GetMysqlConnectingString())

27 } else {

28 db, err = gorm.Open("sqlite3", config.SQLitePath)

29 }

30 if err != nil {

33

34 db.DB().SetMaxIdleConns(10)

35 db.DB().SetMaxOpenConns(50)

36 db.LogMode(true)

37 db.SetLogger(zapgorm.New(log.Logger.WithOptions(zap.AddCallerSkip(7))))

main.go (https://github.com/c-bata/goptuna.git) Go · 104 lines

12 "syscall"

13

14 "gorm.io/driver/sqlite"

15 "gorm.io/gorm"

16

34

35 func main() {

36 db, err := gorm.Open(sqlite.Open("db.sqlite3"), &gorm.Config{})

37 if err != nil {

38 log.Fatal("failed to open database:", err)

41 log.Fatal("failed to get sql.DB:", err)

42 } else {

43 sqlDB.SetMaxOpenConns(1)

44 }

45 err = rdb.RunAutoMigrate(db)

store.go (https://github.com/canonical/go-dqlite.git) Go · 239 lines

15

16 "github.com/canonical/go-dqlite/internal/protocol"

17 _ "github.com/mattn/go-sqlite3" // Go SQLite bindings

18 )

19

46 //

47 // If the filename ends with ".yaml" then the YamlNodeStore implementation will

48 // be used. Otherwise the SQLite-based one will be picked, with default names

49 // for the schema, table and column parameters.

50 //

56

57 // Open the database.

58 db, err := sql.Open("sqlite3", filename)

59 if err != nil {

60 return nil, errors.Wrap(err, "failed to open database")

sqlite3_go113_test.go (git://github.com/mattn/go-sqlite3.git) Go · 119 lines

6 // +build go1.13,cgo

7

8 package sqlite3

9

10 import (

21 defer os.Remove(srcTempFilename)

22

23 db, err := sql.Open("sqlite3", srcTempFilename)

24 if err != nil {

25 t.Fatal(err)

26 }

27

28 db.SetMaxOpenConns(10)

29 db.SetMaxIdleConns(5)

30

mysql.go (https://github.com/longjoy/micro-go-book.git) Go · 36 lines

16 DbConfig := gorose.Config{

17 // Default database configuration

18 Driver: "mysql", // Database driver(mysql,sqlite,postgres,oracle,mssql)

19 Dsn: userMysql + ":" + pwdMysql + "@tcp(" + hostMysql + ":" + portMysql + ")/" + dbMysql + "?charset=utf8&parseTime=true", // 数据库链接

20 Prefix: "", // Table prefix

21 // (Connection pool) Max open connections, default value 0 means unlimit.

22 SetMaxOpenConns: 300,

23 // (Connection pool) Max idle connections, default value is 1.

24 SetMaxIdleConns: 10,

mysql.go (https://github.com/yxhsea/SecKill.git) Go · 42 lines

13 "Default": "mysql_dev",

14 // (Connection pool) Max open connections, default value 0 means unlimit.

15 "SetMaxOpenConns": 300,

16 // (Connection pool) Max idle connections, default value is 1.

17 "SetMaxIdleConns": 10,

28 "protocol": "tcp",

29 "prefix": "", // Table prefix

30 "driver": "mysql", // Database driver(mysql,sqlite,postgres,oracle,mssql)

31 },

32 },

base.db.go (https://github.com/liujianping/scaffold.git) Go · 65 lines

8 _ "github.com/jinzhu/gorm/dialects/mysql"

9 _ "github.com/jinzhu/gorm/dialects/postgres"

10 _ "github.com/jinzhu/gorm/dialects/sqlite"

11 )

12

23 }

24

25 db.DB().SetMaxOpenConns(DefaultMaxOpenConnections)

26 db.DB().SetMaxIdleConns(DefaultMaxIdleConnections)

27 return db, nil

db.go (https://github.com/zou2699/mypipe.git) Go · 83 lines

22 "github.com/jinzhu/gorm"

23 _ "github.com/jinzhu/gorm/dialects/mysql" // mysql

24 _ "github.com/jinzhu/gorm/dialects/sqlite" // sqlite

25 "github.com/zou2699/mypipe/log"

26 "github.com/zou2699/mypipe/model"

31

32 var db *gorm.DB

33 var useSQLite bool

34

35 // ConnectDB connects to the database.

36 func ConnectDB() {

37 var err error

38 useSQLite = false

39 if "" != model.Conf.SQLite {

40 db, err = gorm.Open("sqlite3", model.Conf.SQLite)

41 useSQLite = true

gorm.go (https://github.com/dorajistyle/goyangi.git) Go · 34 lines

15 db, err := gorm.Open("postgres", config.PostgresDSL())

16 // db, err := gorm.Open("mysql", config.MysqlDSL())

17 //db, err := gorm.Open("sqlite3", "/tmp/gorm.db")

18

19 db.DB()

22 db.DB().Ping()

23 db.DB().SetMaxIdleConns(10)

24 db.DB().SetMaxOpenConns(100)

25

26 // Disable table name's pluralization

sqlite.go (https://bitbucket.org/asardak/atm-store.git) Go · 143 lines

15 }

16

17 func (repo *SqliteRepo) Init() bool {

18

19 var err error

36 }

37

38 log.Printf("Seeding data to Sqlite")

39 sqlStmt := `

40 CREATE TABLE items (

140

141 func init() {

142 registerRepo("sqlite", &SqliteRepo{})

143 }

144

example_test.go (https://bitbucket.org/foursource/dbr-internal.git) Go · 162 lines

7

8 func ExampleOpen() {

9 // create a connection (e.g. "postgres", "mysql", or "sqlite3")

10 conn, _ := Open("postgres", "...", nil)

11 conn.SetMaxOpenConns(10)

db_alias.go (https://github.com/assad2008/beego.git) Go · 220 lines

15 _ DriverType = iota

16 DR_MySQL

17 DR_Sqlite

18 DR_Oracle

19 DR_Postgres

38 "mysql": DR_MySQL,

39 "postgres": DR_Postgres,

40 "sqlite3": DR_Sqlite,

41 }

42 dbBasers = map[DriverType]dbBaser{

43 DR_MySQL: newdbBaseMysql(),

44 DR_Sqlite: newdbBaseSqlite(),

45 DR_Oracle: newdbBaseMysql(),

46 DR_Postgres: newdbBasePostgres(),

create.go (https://gitlab.com/IIC2173-2015-2-Grupo2/news-api) Go · 37 lines

14 // db, err := gorm.Open("foundation", "dbname=gorm") // FoundationDB.

15 // db, err := gorm.Open("mysql", "user:password@/dbname?charset=utf8&parseTime=True&loc=Local")

16 // db, err := gorm.Open("sqlite3", "/tmp/gorm.db")

17

18 // You can also use an existing database connection handle

32 db.DB().Ping()

33 db.DB().SetMaxIdleConns(10)

34 db.DB().SetMaxOpenConns(100)

35

36 db.CreateTable(&models.User{})

models.go (https://github.com/max107/online-help.git) Go · 60 lines

5 "github.com/jinzhu/gorm"

6 _ "github.com/lib/pq"

7 _ "github.com/mattn/go-sqlite3"

8 "log"

9 "time"

15 // db, err := gorm.Open("postgres", "user=gorm dbname=gorm sslmode=disable")

16 // db, err := gorm.Open("mysql", "root:12345@/gorm?charset=utf8&parseTime=True")

17 db, _ = gorm.Open("sqlite3", "./chat.db")

18

19 // Get database connection handle [*sql.DB](http://golang.org/pkg/database/sql/#DB)

23 db.DB().Ping()

24 db.DB().SetMaxIdleConns(10)

25 db.DB().SetMaxOpenConns(100)

26

27 // Disable table name's pluralization

init.go (https://gitlab.com/hippora/hippoblog) Go · 22 lines

1 package models

2 import (

3 _ "github.com/mattn/go-sqlite3"

4 "github.com/go-xorm/xorm"

5 "log"

10 func init() {

11 var err error

12 db,err = xorm.NewEngine("sqlite3","test.db")

13 if err != nil {

14 log.Fatal(err)

15 }

16 //engine.SetMaxIdleConns(10)

17 //engine.SetMaxOpenConns(10)

18 db.ShowSQL(true)

19 db.ShowExecTime(true)

database.go (https://github.com/cnbattle/douyin.git) Go · 26 lines

4 "github.com/cnbattle/douyin/internal/database/model"

5 "github.com/jinzhu/gorm"

6 _ "github.com/jinzhu/gorm/dialects/sqlite"

7 "log"

8 )

10 var (

11 Local *gorm.DB

12 localDialect = "sqlite3"

13 localArgs = "./database.db"

14 )

21 }

22 Local.LogMode(false)

23 Local.DB().SetMaxOpenConns(10)

24 Local.DB().SetMaxIdleConns(20)

25 Local.AutoMigrate(&model.Video{})

database.go (https://github.com/cathing/douyin.git) Go · 26 lines

4 "github.com/cnbattle/douyin/model"

5 "github.com/jinzhu/gorm"

6 _ "github.com/jinzhu/gorm/dialects/sqlite"

7 "log"

8 )

10 var (

11 Local *gorm.DB

12 localDialect = "sqlite3"

13 localArgs = "./database.db"

14 )

21 }

22 Local.LogMode(false)

23 Local.DB().SetMaxOpenConns(10)

24 Local.DB().SetMaxIdleConns(20)

25 Local.AutoMigrate(&model.Video{})

dbs.go (https://github.com/velrino/RedFull.git) Go · 19 lines

4 "time"

5 "github.com/jinzhu/gorm"

6 _ "github.com/jinzhu/gorm/dialects/sqlite"

7 )

8

9 func Database() *gorm.DB {

10

11 db, err := gorm.Open("sqlite3", "redventures")

12 if err != nil {

13 panic("failed to connect database")

15 db.DB().SetConnMaxLifetime(time.Minute*5);

16 db.DB().SetMaxIdleConns(0);

17 db.DB().SetMaxOpenConns(5);

18 return db

19 }