pg

What does pg_resetxlog do? And how does it work?

 ̄綄美尐妖づ 提交于 2019-12-03 16:00:25
I have looked at the postgres documentation and the synopsis below is given: pg_resetxlog [-f] [-n] [-ooid ] [-x xid ] [-e xid_epoch ] [-m mxid ] [-O mxoff ] [-l timelineid,fileid,seg ] datadir But at no point in the documentation do they explain what the datadir is. Is it the %postgres-path%/9.0/data or could it be %postgres-path%/9.0/data/pgxlog ? Also, if I want to change my xlog directory, can I simply move the items in my current pg_xlog directory and run the command to point to another directory? (Assume my current pg_xlog directory is in /data1/postgres/data/pg_xlog AND the directory I

Install libpq-dev package error

蓝咒 提交于 2019-12-03 12:57:32
问题 I tried to install pg gem and I have had this warning: You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application. So I tried install libpq-dev package and I have had this warning: libpq-dev : Depends: libpq5 (= 8.4.17-0squeeze1) but 9.1.9-1~bpo60+1 is to be installed How to fix this? 回答1: This should let you install the package you need :) Just tried it myself, I am not sure you will need all the packages on the

Example of a prepared INSERT statement using ruby pg gem

半腔热情 提交于 2019-12-03 12:10:54
问题 Did some googling for about half a day and I can't find any sample of a prepared INSERT statement using the pg gem (postgresql ruby gem). I tried this (after looking at the gem docs): def test2 conn = PG.connect( dbname: 'db1' ) conn.prepare("statement1", 'INSERT INTO table1 (id, name, profile) VALUES (?, ?, ?)') end But I get the following error: pgtest.rb:19:in `prepare': ERROR: syntax error at or near "," (PG::Error) LINE 1: INSERT INTO table1 (id, name, profile) VALUES (?, ?, ?) ^ from

Rails raw query for csv format, to be returned via controller

浪尽此生 提交于 2019-12-03 09:59:18
问题 I was using active record to get my stories and then generate a CSV, the standard way as done in the rails cast. But I have a lot of rows and it takes minutes. I think if I could get posgresql to do the csv rendering, then I could save some time. Heres what I have right now: query = "COPY stories TO STDOUT WITH CSV HEADER;" results = ActiveRecord::Base.connection.execute(query); But the results are empty for this query: => #<PG::Result:0x00000006ea0488 @connection=#<PG::Connection

when to disconnect and when to end a pg client or pool

南笙酒味 提交于 2019-12-03 09:38:35
My stack is node, express and the pg module. I really try to understand by the documentation and some outdated tutorials. I dont know when and how to disconnect and to end a client. For some routes I decided to use a pool. This is my code const pool = new pg.Pool({ user: 'pooluser',host: 'localhost',database: 'mydb',password: 'pooluser',port: 5432}); pool.on('error', (err, client) => { console.log('error ', err); process.exit(-1); }); app.get('/', (req, res)=>{ pool.connect() .then(client => { return client.query('select ....') .then(resolved => { client.release(); console.log(resolved.rows);

Install libpq-dev package error

落爺英雄遲暮 提交于 2019-12-03 03:10:53
I tried to install pg gem and I have had this warning: You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application. So I tried install libpq-dev package and I have had this warning: libpq-dev : Depends: libpq5 (= 8.4.17-0squeeze1) but 9.1.9-1~bpo60+1 is to be installed How to fix this? This should let you install the package you need :) Just tried it myself, I am not sure you will need all the packages on the second line, try it and see :) apt-get update apt-get install libxslt-dev libxml2-dev libpam-dev libedit-dev

Rails raw query for csv format, to be returned via controller

狂风中的少年 提交于 2019-12-02 23:09:11
I was using active record to get my stories and then generate a CSV, the standard way as done in the rails cast. But I have a lot of rows and it takes minutes. I think if I could get posgresql to do the csv rendering, then I could save some time. Heres what I have right now: query = "COPY stories TO STDOUT WITH CSV HEADER;" results = ActiveRecord::Base.connection.execute(query); But the results are empty for this query: => #<PG::Result:0x00000006ea0488 @connection=#<PG::Connection:0x00000006c62fb8 @socket_io=nil, @notice_receiver=nil, @notice_processor=nil>> 2.0.0-p247 :053 > result.count => 0

Error: sorry, too many clients already

岁酱吖の 提交于 2019-12-02 17:24:58
问题 I am using PostgreSQL in my NodeJS backend service. All of sudden, when I start the service I am facing below error connection error error: sorry, too many clients already. PostgresSQL connection config const pg = require(“pg”); const client = new pg.Client({ host: “txslmxxxda6z”, user: “mom”, password: “mom”, db: “mom”, port: 5025 }); I am unable to query database because of the above error. I am unable to fix this issue. Can you please suggest the solution 回答1: below query will help you.

How to fix “PG::Error: Wait on socket” error when accessing Postgres DB in Rails 3 app

爷,独闯天下 提交于 2019-12-02 10:03:12
One of our application is built on Rails 3 which uses postgres as database. We observe that while doing load test i.e continuously submitting request, there are random exceptions related to database (comes from postgres_adapter): 1. PG::Error: Wait on socket error (WaitForMultipleObjects): 2. NoMethodError: undefined method `result_error_field' for nil:NilClass: I am not able to find any reference on cause of these issues as they're coming at different points. Any help on how to avoid this or solve this would be helpful. Thanks 来源: https://stackoverflow.com/questions/58318742/how-to-fix

Error Installing PG Gem on Windows

你离开我真会死。 提交于 2019-12-02 08:22:20
I'm using XAMPP as my installation folder for PostgreSQL 9.3. C:\xampp\pgsql\9.3 And now I'm trying to install PostgreSQL gem using that directory as a reference: gem install pg -- --with-pg-include="C:\xampp\pgsql\9.3\include" --with-pg-lib="C:\xampp\pgsql\9.3\lib" --with-pg-config="C:\xampp\pgsql\9.3\bin\pg_config" But this command failed with errors listed below: ERROR: Error installing pg: ERROR: Failed to build gem native extension. C:/Ruby/Ruby200/bin/ruby.exe extconf.rb --with-pg-include=C:\xampp\pgsql\9.3 \include --with-pg-lib=C:\xampp\pgsql\9.3\lib --with-pg-config=C:\xampp\pgsql\9.