···2222 return db
2323}
24242525+func AddAttachments(db *sql.DB, attachments map[string]string) error {
2626+ for name, dbPath := range attachments {
2727+ fullpath, err := filepath.Abs(dbPath)
2828+2929+ if err != nil {
3030+ return err
3131+ }
3232+3333+ _, err = db.Exec(fmt.Sprintf("ATTACH DATABASE '%s' AS %s", fullpath, name))
3434+3535+ if err != nil {
3636+ return err
3737+ }
3838+ }
3939+4040+ return nil
4141+}
4242+2543// For this application, we use multiple database that do have to interact with each other. This
2644// function opens the databases with correct names and paths to the database. The databases will be
2745// opened with WAL mode and normal synchronous mode.