postgresql-9.1

How does one drop a template database from PostgreSQL?

房东的猫 提交于 2019-12-02 16:07:38
postgres=# DROP DATABASE template_postgis; ERROR: cannot drop a template database http://www.postgresql.org/docs/9.1/static/manage-ag-templatedbs.html makes it seem like if I set template_postgis.datistemplate = false , I'll be able to drop it, but I don't know how to set that. postgres=# UPDATE pg_database SET datistemplate='false' WHERE datname='template_postgis'; UPDATE 1 postgres=# DROP DATABASE template_postgis; DROP DATABASE postgres=# You can use the alter database command. Much simpler and safer than upsetting metadata. postgres=# create database tempDB is_template true; CREATE

How to set up Postgres database for local Rails project?

China☆狼群 提交于 2019-12-02 14:54:41
I recently got a new machine and would now like to work on my projects from Github. I'm curious as to how to properly set up the Postgres database on my local machine. I have postgresql , pgadmin3 and libpq-dev installed on Ubuntu (12.04). I pull down the project: git clone https://github.com/thebenedict/cowsnhills.git and run: bundle . When I run: rake db:create && rake db:schema:load I get this error: rake db:create && rake db:schema:load FATAL: password authentication failed for user "cnh" FATAL: password authentication failed for user "cnh" .... The config/database.yml file looks like this

ERROR: relation does not exist

蹲街弑〆低调 提交于 2019-12-02 13:58:12
问题 So here is the problem. I am scraping some data with java and eventually i place that java into postgres database. When i run Java program, i get error ERROR: relation "table name" does not exist but when i personally write that same query in PGAdmin III, it works fine. I googled it and it's not about caps letters that most people have problems with. Here is a screenshot: 回答1: My first thought was that you were using double quotes for values, but then I looked again and realized you were

How do I save one piece of data in two databases using OpenERP?

断了今生、忘了曾经 提交于 2019-12-02 11:10:51
When I want to edit code in OpenERP, is it possible to save one piece of data in two databases where the fields have the same names in both tables. Yes it is quite possible if you know the database but let me warn you this is very bad idea cause it is very risky and all rule of Resistance layer (ORM) will be violated. What are you actually trying to do?? If you are trying to synchronize, then use the module base_synchro . The module is not complete. You have to do your own customization in that module 来源: https://stackoverflow.com/questions/11424880/how-do-i-save-one-piece-of-data-in-two

ERROR: relation does not exist

痞子三分冷 提交于 2019-12-02 08:01:09
So here is the problem. I am scraping some data with java and eventually i place that java into postgres database. When i run Java program, i get error ERROR: relation "table name" does not exist but when i personally write that same query in PGAdmin III, it works fine. I googled it and it's not about caps letters that most people have problems with. Here is a screenshot: My first thought was that you were using double quotes for values, but then I looked again and realized you were assembling a query using string concatenation. DON'T DO THAT. In addition to making these problems impossible to

PLPGSQL Function to Calculate Bearing

爱⌒轻易说出口 提交于 2019-12-02 07:01:14
Basically I can't get my head around the syntax of plpgsql and would appreciate some help with the following efforts. I have a table containing 1000's of wgs84 points. The following SQL will retrieve a set of points within a bounding box on this table: SELECT id, ST_X(wgs_geom), ST_Y(wgs_geom), ST_Z(wgs_geom) FROM points_table INNER JOIN (SELECT ST_Transform(ST_GeomFromText('POLYGON((-1.73576102027 1.5059743629, -1.73591122397 51.5061067655,-1.73548743495 51.5062838333,-1.73533186682 1.5061514313,-1.73576102027 51.5059743629))', 4326, 27700) ) AS bgeom ) AS t2 ON ST_Within(local_geom, t2.bgeom

Attribute number 10 exceeds number of columns 0

我只是一个虾纸丫 提交于 2019-12-02 04:18:36
This query returns all the rows(around 850+) from the table successfully: select * from my_db_log where date_trunc('day',creation_date) >= to_date('2014-03-05'::text,'yyyy-mm-dd'); But when I add the count(*) with the same query like below: select count(*) from my_db_log where date_trunc('day',creation_date) >= to_date('2014-03-05'::text,'yyyy-mm-dd'); Then it returns me: ********** Error ********** ERROR: attribute number 10 exceeds number of columns 0 SQL state: XX000 FYI: creation_date is the 10th column of my table. Interestingly, when i replace count(*) with count(id) then it returns me 0

Laravel - using a postgre bytea blob field

青春壹個敷衍的年華 提交于 2019-12-01 21:16:42
问题 I am using PostgreSQL on a Laravel installation. A table has a bytea type field which is being used to store binary data (base64_encoded file contents). When I use Eloquent to retrieve the table I get a resource type variable being returned in this field. How can I rather retrieve this as a string? $raw = Media::where('id','=',$id)->first(); $raw->file_data = base64_decode($raw->file_data); // doesn't work 回答1: As the author of this question did not post the details to the answer, I will post

Postgres function returning one record while I have many records?

别来无恙 提交于 2019-12-01 20:47:48
I have many records which my simple query returning but when i use function it just gives me first record, firstly i create my own data type using, CREATE TYPE my_type (usr_id integer , name varchar(30)); and my function is, CREATE OR REPLACE function test() returns my_type as $$ declare rd varchar := '21'; declare personphone varchar := NULL; declare result my_type; declare SQL VARCHAR(300):=null; DECLARE radiophone_clause text = ''; BEGIN IF rd IS NOT NULL then radiophone_clause = 'and pp.radio_phone = '|| quote_literal(rd); END IF; IF personphone IS NOT NULL then radiophone_clause =

Laravel - using a postgre bytea blob field

空扰寡人 提交于 2019-12-01 18:41:14
I am using PostgreSQL on a Laravel installation. A table has a bytea type field which is being used to store binary data (base64_encoded file contents). When I use Eloquent to retrieve the table I get a resource type variable being returned in this field. How can I rather retrieve this as a string? $raw = Media::where('id','=',$id)->first(); $raw->file_data = base64_decode($raw->file_data); // doesn't work As the author of this question did not post the details to the answer, I will post my findings here. As the returned field is a handle to a stream you can use the stream_get_contents