ADD: added initial page with login
This commit is contained in:
@@ -1 +1,32 @@
|
||||
package database
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
_ "github.com/lib/pq" // Import the PostgreSQL driver
|
||||
)
|
||||
|
||||
const playerTable = `
|
||||
CREATE TABLE IF NOT EXISTS players (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name VARCHAR(100) NOT NULL,
|
||||
age INT NOT NULL,
|
||||
birthday DATE NOT NULL
|
||||
);
|
||||
`
|
||||
|
||||
func InitTables(db *sql.DB) {
|
||||
tables := []string{
|
||||
playerTable,
|
||||
}
|
||||
|
||||
for _, table := range tables {
|
||||
if _, err := db.Exec(table); err != nil {
|
||||
log.Fatalf("Error creating table: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Println("Tables initialized successfully.")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user