Compare commits
3 Commits
v0.1.0
...
8c317fc3b6
Author | SHA1 | Date | |
---|---|---|---|
8c317fc3b6 | |||
efc047c965 | |||
5e9ba524e9 |
15
sqlite.go
15
sqlite.go
@@ -18,7 +18,6 @@ type database struct {
|
||||
}
|
||||
|
||||
type Database interface {
|
||||
Connect() error
|
||||
Close() error
|
||||
Exec(ctx context.Context, query string, args ...any) (sql.Result, error)
|
||||
Query(ctx context.Context, query string, args ...any) (*sqlx.Rows, error)
|
||||
@@ -43,19 +42,13 @@ func New(opts ...Option) (Database, error) {
|
||||
opt(db)
|
||||
}
|
||||
|
||||
return db, nil
|
||||
}
|
||||
|
||||
// connects to database file
|
||||
func (d *database) Connect() error {
|
||||
db, err := sqlx.Open("sqlite3", fmt.Sprintf("file:%s/%s", d.path, d.file))
|
||||
slite, err := sqlx.Open("sqlite3", fmt.Sprintf("file:%s/%s", db.path, db.file))
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
db.sqlite = slite
|
||||
|
||||
d.sqlite = db
|
||||
|
||||
return nil
|
||||
return db, nil
|
||||
}
|
||||
|
||||
// closes database file connection
|
||||
|
Reference in New Issue
Block a user