mirror of
				https://github.com/ClusterCockpit/cc-backend
				synced 2025-10-31 07:55:06 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			26 lines
		
	
	
		
			277 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			26 lines
		
	
	
		
			277 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package test
 | |
| 
 | |
| import (
 | |
| 	"fmt"
 | |
| 	"os"
 | |
| 
 | |
| 	"github.com/jmoiron/sqlx"
 | |
| )
 | |
| 
 | |
| func InitDB() *sqlx.DB {
 | |
| 
 | |
| 	bp := "./"
 | |
| 	ebp := os.Getenv("BASEPATH")
 | |
| 
 | |
| 	if ebp != "" {
 | |
| 		bp = ebp + "test/"
 | |
| 	}
 | |
| 
 | |
| 	db, err := sqlx.Open("sqlite3", bp+"test.db")
 | |
| 	if err != nil {
 | |
| 		fmt.Println(err)
 | |
| 	}
 | |
| 
 | |
| 	return db
 | |
| }
 |