sillyquill

command module
v0.0.0-...-a4b336c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 24, 2016 License: BSD-2-Clause Imports: 15 Imported by: 0

README

#Sillyquill

Sillyquill is a tool for generating Golang code from an exising Postgres database.

The generated code models each row as an instance of a struct. The API supports basic CRUD semantics, but can also handle rows from your own SQL queries. The generated code is built on top of the project github.com/lib/pq.

##Example usage of generated code

Creating a new row in the users table.


u := new(dal.User)
u.SetName("foobar")
u.SetEmail("foo@bar.com")
err := u.Save(dbconn)
//Check the value of err

Lookup the same user in the users table by the name column.


u := new(dal.User)
u.SetName("foobar")
err := u.Get(dbconn)
//Check the value of err

Lookup the same user, but only load the email column.

u := new(dal.User)
u.SetName("foobar")
err := u.Get(dbconn,dal.Users.Email)
//Check the value of err

##Quick Start

Create a file called sillyquill.toml. Place it in the following

db= "<full connection string passed to github.com/lib/pq>"
output-dir= "/the/full/path/to/generate/to"
package= "<name of package to generate>"

Run the following commands

go get github.com/hydrogen18/sillyquill
go install github.com/hydrogen18/sillyquill
$GOPATH/bin/sillyquill #In the directory with sillyquill.toml

Sillyquill now runs and generates source files in the configured directory.

###TODO

  1. Foreign key support
  2. Schema support

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package dec implements multi-precision decimal arithmetic.
Package dec implements multi-precision decimal arithmetic.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL