Thanks Sijo,
I ended up using something very similar:
pg_conn = self.connection.instance_variable_get(:@connection)
pg_conn.exec("COPY (#{sql}) TO STDOUT WITH CSV HEADER")
csv = []
while (line = pg_conn.getline) != "\\."
csv << line
end
pg_conn.endcopy
csv.join("\n")
It's a hack but it works
ead '/tmp/file.csv'
=> "email,fname,lname,created_at \n...@example.com,Foo,Fooster,
2009-07-07 17:00:41.929865\n...@example.com,Bar,Barbie,2009-07-01
20:31:08.659965\nu...@example.com,User,User,2009-07-07
20:33:53.293606\nad...@example.com,Admin,Admin,2009-07-07
20:33:53.760538\n&
Thanks Philip,
The Postgres gem rdoc hasn't been much help. All of the PGresult
instance methods that retrieve values require a tuple number. My
PGresult has a number of fields, but not tuples (rows).
This query (when run in psql) returns a large block of text. For
example:
email,fname,lname,cr
I'm using ActiveRecord's connection to execute a custom query (which
runs fine in psql) like this:
>> result = ActiveRecord::Base.connection.execute("COPY (select * from users)
>> TO STDOUT WITH CSV;")
SQL (0.8ms) COPY (select * from users) TO STDOUT WITH CSV;
=> #
>> result.nfields
=> 39
>>
Howdy,
I'm having some trouble migrating.
>From a fresh db, rake db:migrate runs successfully, with no errors.
The tasks in the latest migration are performed with no problem.
However, the latest version # is not saved in the schema_migrations
table. All other version numbers are.
Subsequent r
I don't know of any, sorry.
In the past I've written two simple instance methods and two
named_scopes in my models.
named_scope :next, lambda {|post, user|
{ :conditions => ["created_at > ? and user_id = ?", post.created_at,
user.id], :order => "created_at ASC" }
}
named_scope :prev, lambda {
I've done so in the past with the Time class.
((Time.now-past_date)/1.year).round
On Nov 20, 10:42 pm, "James Englert" <[EMAIL PROTECTED]> wrote:
> Hey,
> I need to get the number of years (as a number) between two dates. Here is
> what I have as a helper.
>
> # Returns the number of years b
Hi All,
I'm trying to add a marker with an info_window on my map in a rjs
request using a partial.
new.js.rjs
marker = GMarker.new([EMAIL PROTECTED], @bar.lng], :info_window => render
(:partial => "/foo/bar", :object => @bar))
page << @map.record_global_init(marker.declare('new_bar'))
8 matches
Mail list logo