Advertisement
arxeiss

DB Connection

May 1st, 2016
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.28 KB | None | 0 0
  1. import (
  2.     "database/sql"
  3.     _ "github.com/mattn/go-sqlite3"
  4. )
  5. func ConnectToDB(file string, schema string) error {
  6.     db, err := sql.Open("sqlite3", file)
  7.     if err != nil {
  8.         return err
  9.     }
  10.     if _, err = db.Exec("PRAGMA foreign_keys = ON"); err != nil {
  11.         return err
  12.     }
  13.     return nil
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement