Skip to content

How to get current connection name #561

Open
@jacentsao

Description

@jacentsao

Hi mattn,
Recently i changed our journal_mode from DELETE to WAL due to database lock problem, after this i meet backup problem, we used to just copy file to backup the sqlite database, it's okay to do this. But using wal it cannot doing so, and using the backup function in hook. Here is my code:

	destDb, err := sql.Open(driverName,bakf)
	if err != nil {
		beego.Error(err)
	}
	defer destDb.Close()
	destDb.Ping()
	bk, err := sqlite3conn[1].Backup("main",sqlite3conn[0], "main")
	if err != nil {
		beego.Error(err)
	}
	_, err = bk.Step(-1)
	if err != nil {
		beego.Error(err)
	}
	bk.Finish()

But in our app we will dynamic open many db file , and in some situation i cannot just using index to backup the database, is there any function to distinguish the connection file name or something else. Many thanks

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions