summary refs log tree commit diff stats
path: root/lib/pure/oids.nim
Commit message (Expand)AuthorAgeFilesLines
* remove deprecated stuff from the stdlib; introduce better deprecation warningsAraq2018-05-051-4/+2
* Sub second time resolution (#6978)Oscar NihlgÄrd2018-04-131-1/+1
* Better times module (#6552)GULPF2017-12-181-1/+1
* fix redundant time import with different signature (#5715)Jacek Sieka2017-04-161-2/+1
* Fixed race condition in genOid()Ruslan Mustakov2016-08-231-2/+1
* Added == operator for comparing two Object IDsRostyslav Dzinko2015-09-081-0/+4
* lib: Trim .nim files trailing whitespaceAdam Strzelecki2015-09-041-9/+9
* Don't run non-test code when defined(testing)Oleh Prypin2015-04-211-1/+1
* Remove extra trailing zero from oidFlaviu Tamas2014-11-021-1/+1
* several modules changedAraq2014-08-281-1/+1
* big renameAraq2014-08-271-9/+11
* Fix more 'undeclared identifier' errors.EXetoC2014-05-141-2/+2
* stdlib compiles mostly without warnings againAraq2014-02-061-1/+1
* added $ for oidsAraq2013-10-311-1/+5
* changed integer promotion rules; breaks bootstrapping and lots of codeAraq2012-07-081-1/+2
* better opengl wrapper; oids and endians modules documentedAraq2012-04-041-4/+9
* added libsvm wrapperAraq2012-04-041-0/+81
f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
package storage

import (
	"database/sql"
	"fmt"
	"log"
	"sync"
)

// DB holds the database connection, mutex & path.
type DB struct {
	Path string
	Mu   *sync.RWMutex
	Conn *sql.DB
}

// Init initializes the database.
func Init() *DB {
	db := DB{
		Mu: new(sync.RWMutex),
	}

	initDB(&db)
	return &db
}

// InitConn initializes database connection.
func InitConn() *DB {
	var err error
	db := DB{
		Mu: new(sync.RWMutex),
	}

	db.Path = fmt.Sprintf("%s/grus.db", GetDir())

	db.Conn, err = sql.Open("sqlite3", db.Path)
	if err != nil {
		log.Printf("storage/init.go: %s\n",
			"Failed to open database connection")
		initErr(&db, err)
	}

	return &db
}