postgresql-9.2

Socket File “/var/pgsql_socket/.s.PGSQL.5432” Missing In Mountain Lion (OS X Server)

China☆狼群 提交于 2019-11-28 15:08:50
I just upgraded my MacMini Server from Lion Server to Mountain Lion using OS X Server. I am having the same problem with PostgreSQL that I did last year when I first installed Lion Server. When I try to do any kind of PostgreSQL terminal command I get the following notorious error message that many have gotten over the years: psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"? I was attempting to change the password for _postgres when I got the error. I tried several

How to write a function that returns text or integer values?

笑着哭i 提交于 2019-11-28 12:46:04
I'm using PostgreSQL 9.2.4. postgres=# select version(); version ------------------------------------------------------------- PostgreSQL 9.2.4, compiled by Visual C++ build 1600, 64-bit (1 row) sqlfiddle link My Query executes the insertion safely. What i need is that my function should return something except the void datatype. Something like text("inserted into table") or integer(0-false,1-true) , it will be useful for me to validate whether it is inserted or not? I need a syntax for a function that returns an integer or a text when an insertion is done. For validation purpose. Is there any

Find out which schema based on table values

丶灬走出姿态 提交于 2019-11-28 12:39:28
My database is separated into schemas based on clients (i.e.: each client has their own schema, with same data structure). I also happen to have an external action that does not know which schema it should target. It comes from another part of the system that has no concepts of clients and does not know in which client's set it is operating. Before I process it, I have to find out which schema that request needs to target To find the right schema, I have to find out which holds the record R with a particular unique ID (string) From my understanding, the following SET search_path TO schema1

Importing .csv with timestamp column (dd.mm.yyyy hh.mm.ss) using psql \\copy

泪湿孤枕 提交于 2019-11-28 12:10:48
I'm trying to import data from a .csv file into a postgresql 9.2 database using the psql \COPY command (not the SQL COPY). The input .csv file contains a column with a timestamp in the dd.mm.yyyy hh.mm.ss format. I've set the database datestyle to DMY using. set datestyle 'ISO,DMY' Unfortunately, when I run the \COPY command: \COPY gc_test.trace(numpoint,easting,northing,altitude,numsats,pdop,timestamp_mes,duration,ttype,h_error,v_error) FROM 'C:\data.csv' WITH DELIMITER ';' CSV HEADER ENCODING 'ISO 8859-1' I get this error: ERROR: date/time field value out of range: "16.11.2012 07:10:06" HINT

Failed to find conversion function from unknown to text

怎甘沉沦 提交于 2019-11-28 11:52:13
In one of my select statements I've got the following error: ERROR: failed to find conversion function from unknown to text ********** Error ********** ERROR: failed to find conversion function from unknown to text SQL state: XX000 This was easy to fix using cast , but I do not fully understand why it happened. I will ilustrate my confusion with two simple statements. This one is OK: select 'text' union all select 'text'; This will return error: with t as (select 'text') select * from t union all select 'text' I know I can fix it easily: with t as (select 'text'::text) select * from t union

How to create sequence if not exists

大兔子大兔子 提交于 2019-11-28 09:42:53
I tried to use code from Check if sequence exists in Postgres (plpgsql) . To create sequence if it does not exists. Running this code two times causes an exception: sequence ... already exists. How to create sequence only if it does not exist? If the sequence does not exist, no message should be written and no error should occur so I cannot use the stored procedure in the other answer to this question since it writes message to log file every time if sequence exists. do $$ begin SET search_path = ''; IF not EXISTS (SELECT * FROM pg_class WHERE relkind = 'S' AND oid::regclass::text = 'firma1.'

How do I start enterpiseDB PostgreSQL on Mac OSX 10.6.8?

允我心安 提交于 2019-11-28 08:51:07
Mac OSX 10.6.8 The postgres website says postgres 9.2+ is compatible with Mac OSX 10.6+, so I downloaded the 9.2.4 version of the installer for Mac OSX here: http://www.enterprisedb.com/products-services-training/pgdownload I accepted all the defaults, so postgres was installed in the directory: /Library/PostgreSQL/9.2 (If you are installing postgres for rails development, in order to install the pg gem you need to add to your PATH: http://excid3.com/blog/installing-postgresql-and-pg-gem-on-mac-osx/#.UfkImuB6gy5 ) Now, I am trying to figure out how to use postgres. I found a stackoverflow

The local psql command could not be located

心已入冬 提交于 2019-11-28 07:14:21
问题 I'm following the instructions found here. When I try to run $ heroku pg:psql or $ heroku pg:psql HEROKU POSTGRESQL_BROWN I recieve the following error message: ! The local psql command could not be located ! For help installing psql, see local-postgresql I can't find anything useful on the link it gives me (it just links to the instructions I was already using, but further down the page) nor can I find this error anywhere else. If I've missed anything you need to know to answer this, just

How to return only work time from reservations in PostgreSql?

烂漫一生 提交于 2019-11-28 01:27:15
问题 Select from great answer in How to find first free time in reservations table in PostgreSql create table reservation (during tsrange, EXCLUDE USING gist (during WITH &&) ); is used to find gaps in schedule starting at given date and hour (2012-11-17 8: in sample below) It finds saturday, sunday and public holidays also. Public holidays are defined in table create table pyha ( pyha date primary key) How to exclude weekends and public holidays also? Hard-coding free time as reserved to query

Creating partial unique index with sqlalchemy on Postgres

折月煮酒 提交于 2019-11-27 22:47:19
SQLAlchemy supports creating partial indexes in postgresql . Is it possible to create a partial unique index through SQLAlchemy? Imagine a table/model as so: class ScheduledPayment(Base): invoice_id = Column(Integer) is_canceled = Column(Boolean, default=False) I'd like a unique index where there can be only one "active" ScheduledPayment for a given invoice. I can create this manually in postgres: CREATE UNIQUE INDEX only_one_active_invoice on scheduled_payment (invoice_id, is_canceled) where not is_canceled; I'm wondering how I can add that to my SQLAlchemy model using SQLAlchemy 0.9. class