func AddNewApiKey(db *sql.DB, apiKey string, keyMsg string) error {
	err := checkKeyFormat(apiKey)
	if err != nil {
		return fmt.Errorf("api key rejected: %s", err)
	}

	// Insert it into the database. Duplicate entries will be rejected.
	insertSQL := `INSERT INTO api_keys (apiKey, createdDate, createMsg) VALUES (?, ?, ?)`
	statement, err := db.Prepare(insertSQL)
	_, err = statement.Exec(apiKey, time.Now().Format(time.RFC3339), keyMsg)
	if err != nil {
		return fmt.Errorf("failed to add api key to db: %s", err)
	}

	return nil
}
// AddNewApiKey adds a given key and message to the keys table. Invalid keys are rejected.
AddNewApiKey adds a given key and message to the keys table. Invalid keys are rejected.
// AddNewApiKey adds a given key and message to the keys table . Invalid keys are rejected .
func AddNewApiKey(db *sql.DB, apiKey string, keyMsg string) error {
	err := checkKeyFormat(apiKey)
	if err != nil {
		return fmt.Errorf("api key rejected: %s", err)
	}
	insertSQL := `INSERT INTO api_keys (apiKey, createdDate, createMsg) VALUES (?, ?, ?)`
	statement, err := db.Prepare(insertSQL)
	_, err = statement.Exec(apiKey, time.Now().Format(time.RFC3339), keyMsg)
	if err != nil {
		return fmt.Errorf("failed to add api key to db: %s", err)
	}
	return nil
}
func AddNewApiKey ( db * sql . DB , apiKey string , keyMsg string ) error { err := checkKeyFormat ( apiKey ) if err != nil { return fmt . Errorf ( " " , err ) } insertSQL := `INSERT INTO api_keys (apiKey, createdDate, createMsg) VALUES (?, ?, ?)` statement , err := db . Prepare ( insertSQL ) _ , err = statement . Exec ( apiKey , time . Now ( ) . Format ( time . RFC3339 ) , keyMsg ) if err != nil { return fmt . Errorf ( " " , err ) } return nil }
AddNewApiKey adds a given key and message to the keys table.
AddNewApiKey adds a given key and message to the keys table .
// Insert it into the database. Duplicate entries will be rejected.