Can’t find the ‘libpq-fe.h header when trying to install pg gem

It looks like in Ubuntu that header is part of the libpq-dev package (at least in the following Ubuntu versions: 11.04 (Natty Narwhal), 10.04 (Lucid Lynx), 11.10 (Oneiric Ocelot), 12.04 (Precise Pangolin), 14.04 (Trusty Tahr) and 18.04 (Bionic Beaver)): So try installing libpq-dev or its equivalent for your OS: For Ubuntu/Debian systems: sudo apt-get install libpq-dev On Red Hat Linux (RHEL) systems: yum install postgresql-devel For Mac Homebrew: brew install postgresql For Mac MacPorts PostgreSQL: gem install pg — –with-pg-config=/opt/local/lib/postgresql[version number]/bin/pg_config … Read more

Postgresql: Scripting psql execution with password

To answer your question, there are several ways provide a password for password-based authentication: Via the password prompt. Example: psql -h uta.biocommons.org -U foo Password for user foo: In a pgpass file. See libpq-pgpass. Format: <host>:<port>:<database>:<user>:<password> With the PGPASSWORD environment variable. See libpq-envars. Example: export PGPASSWORD=yourpass psql … # Or in one line for this … Read more

Insert text with single quotes in PostgreSQL

String literals Escaping single quotes ‘ by doubling them up -> ” is the standard way and works of course: Plain single quotes (ASCII / UTF-8 code 39), mind you, not backticks `, which have no special purpose in Postgres (unlike certain other RDBMS) and not double-quotes “, used for identifiers. In old versions or if you still run with standard_conforming_strings = … Read more

Simple Random Samples from a Sql database

There’s a very interesting discussion of this type of issue here: http://www.titov.net/2005/09/21/do-not-use-order-by-rand-or-how-to-get-random-rows-from-table/ I think with absolutely no assumptions about the table that your O(n lg n) solution is the best. Though actually with a good optimizer or a slightly different technique the query you list may be a bit better, O(m*n) where m is the number … Read more

FATAL: password authentication failed for user “postgres” (postgresql 11 with pgAdmin 4)

The default authentication mode for PostgreSQL is set to ident. You can access your pgpass.conf via pgAdmin -> Files -> open pgpass.conf That will give you the path of pgpass.conf at the bottom of the window (official documentation). After knowing the location, you can open this file and edit it to your liking. If that doesn’t work, you can: … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)