Coder Social home page Coder Social logo

Comments (5)

chenjianhao66 avatar chenjianhao66 commented on June 17, 2024

目前项目没有提供sql文件,是因为使用了Grom库的自动迁移功能,具体代码位置在internal/storage/mysql/mysql.go AutoMigrate 方法。

// New 根据MySQL选项去构建gorm对象
func New(opts *config.MySQLOptions) (*gorm.DB, error) {
	dsn := fmt.Sprintf(`%s:%s@tcp(%s)/%s?charset=utf8&parseTime=%t&loc=%s`,
		opts.Username,
		opts.Password,
		fmt.Sprintf("%s:%s", opts.Host, opts.Port),
		opts.Database,
		true,
		"Local")
	db, err := gorm.Open(mysql.Open(dsn), getConfig())

	if err != nil {
		return nil, err
	}

	sqlDB, err := db.DB()
	if err != nil {
		return nil, err
	}

	// 设置最多连接数
	sqlDB.SetMaxOpenConns(opts.MaxOpenConnections)

	// 设置最多可重用连接
	sqlDB.SetConnMaxLifetime(opts.MaxConnectionLifeTime)

	// 设置最多空闲连接池里的最多连接数
	sqlDB.SetMaxIdleConns(opts.MaxIdleConnections)

	err = db.AutoMigrate(model.Device{}, model.MediaDetail{}, model.Channel{})

	return db, err
}

from go-gb28181.

dolpstar avatar dolpstar commented on June 17, 2024

感谢,已经找到了,以后多向大佬学习,为项目完善做一些贡献

from go-gb28181.

chenjianhao66 avatar chenjianhao66 commented on June 17, 2024

好的,我关闭issue了

from go-gb28181.

dolpstar avatar dolpstar commented on June 17, 2024

大佬有没有交流群啊

from go-gb28181.

chenjianhao66 avatar chenjianhao66 commented on June 17, 2024

大佬有没有交流群啊

还没有,目前功能和问题通过issue都还可以解决,后续太多了再考虑创建交流群沟通。

from go-gb28181.

Related Issues (6)

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.