add revenue now workd through shell command

This commit is contained in:
samantha42
2026-03-24 21:31:01 +01:00
parent 7e2c332e60
commit 63be7b9282
13 changed files with 200 additions and 78 deletions

View File

@@ -0,0 +1,25 @@
package database
import (
"Portifolio/internal/model"
"database/sql"
"fmt"
_ "github.com/mattn/go-sqlite3"
)
func GetCompanyByID(db *sql.DB, id int) (*model.Company, error) {
var c model.Company
err := db.QueryRow(
`SELECT id, name, shares_outstanding, price, currency_id FROM companies WHERE id = ?`,
id,
).Scan(&c.ID, &c.Name, &c.SharesOutstanding, &c.Price, &c.CurrencyID)
if err == sql.ErrNoRows {
return nil, nil
}
if err != nil {
return nil, fmt.Errorf("query company: %w", err)
}
return &c, nil
}