Connecting to a Database

Before any data transaction can occur, you must connect to the database first. First, a reminder on our development configuration in config/database.yml

  dialect: "sqlite3"
  database: "./development.sqlite"

Here's how it's done in main.go.

package main

import (

func main() {
    tx, err := pop.Connect("development")
    if err != nil {

There's not a whole lot going on here, and when you compile it you (hopefully) won't see an error.

$ go build main.go
$ ./main

This example isn't very interesting, but sets the basis for future things to do.

results matching ""

    No results matching ""