Transfer first library files

This commit is contained in:
Achim Rohn
2025-07-27 17:53:07 +02:00
parent e187673510
commit 728cf90236
7 changed files with 196 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
package ersteller_lib
import (
"context"
"database/sql"
_ "github.com/mattn/go-sqlite3"
)
// CreateSQLiteConnpool creates a new SQLite connection pool
func CreateSQLiteConnpool(dbPath string) (*sql.DB, error) {
db, err := sql.Open("sqlite3", dbPath)
if err != nil {
Error("Error while creating connection to the SQLite database!!", err)
return nil, err
}
// Test the connection
err = db.PingContext(context.Background())
if err != nil {
LogError("Could not ping SQLite database: %v", err)
return nil, err
}
// Set connection pool settings
db.SetMaxOpenConns(4)
db.SetMaxIdleConns(2)
return db, nil
}