Project

psql

0.0
No commit activity in last 3 years
No release in over 3 years
A simple ruby library for consuming the `psql` command.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

= 0.9.12
= 0.7.0

Runtime

= 0.5.1
 Project Readme

PSQL

A simple ruby library for consuming the psql command. Created in order to simply and quickly describe a PostgreSQL table without having to go through ActiveRecord, so that's basically all you can do right now.

Installation

Add this line to your application's Gemfile:

gem 'psql'

And then execute:

$ bundle

Or install it yourself as:

$ gem install psql

Usage

If you have the following schema in a database named blog:

              Table "public.posts"
Column Type Modifiers
id integer not null
title character varying(55)
body text
db = PSQL::Database.new 'blog'             # => instance of PSQL::Database
db.table( 'posts' )                        # => instance of PSQL::Table
db.table( 'posts' ).column( 'title' )      # => instance of PSQL::Column
db.table( 'posts' ).column( 'title' ).type # => :string

 # And the grand finale:

PSQL[ 'blog' ][ 'posts' ][ 'title' ].type # => :string

PSQL has no dependency on rails, but it can try and auto-detect your rails database name if RAILS_ENV is set:

ENV[ 'RAILS_ENV' ]        # => "development"
PSQL::Database.new :rails # => attempts to locate database.yml and determine the database name

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request