// Open opens a database connection and sets up the database if it's not been done already
Open opens a database connection and sets up the database if it's not been done already
// Open opens a database connection and sets up the database if it ' s not been done already
func Open(ctx context.Context) *sqlx.DB {
    db, err := sqlx.Connect("pgx", env.Config.ConnectionString)
    if err != nil {
        panic(err)
    }
    if _, err := db.Exec(`CREATE TABLE IF NOT EXISTS charts (
							id TEXT PRIMARY KEY,
							x_axis TEXT NOT NULL,
							data TEXT NOT NULL
						)`); err != nil {
        panic(err)
    }
    return db
}
func Open ( ctx context . Context ) * sqlx . DB { db , err := sqlx . Connect ( " " , env . Config . ConnectionString ) if err != nil { panic ( err ) } if _ , err := db . Exec ( `CREATE TABLE IF NOT EXISTS charts (
							id TEXT PRIMARY KEY,
							x_axis TEXT NOT NULL,
							data TEXT NOT NULL
						)` ) ; err != nil { panic ( err ) } return db }
Open opens a database connection and sets up the database if it's not been done already
Open opens a database connection and sets up the database if it ' s not been done already