postgresql-9.1

Postgresql & psycopg2: database does not exist

别来无恙 提交于 2019-12-12 12:47:05
问题 I am trying to establish a connection to a database like this: psycopg2.connect(database="movies", user="lfcj", host="127.0.0.1"); my pg_hba.conf file has a line: TYPE __ DATABASE___USER__ADDRESS___METHOD local all lfcj peer I am trying to use peer identification, and my SO user name is also lfcj . When I log in postgresql like this, grant all privileges to lfcj , and run \list : psql lfcj -h 127.0.0.1 -d movies Enter password: 'myPassword' psql (9.4.1) SSL connection (protocol: TLSv1.2,

PostgreSQL integer array value join to integer in other table with desc string

可紊 提交于 2019-12-12 10:37:03
问题 I have a table test column with int arrays and values like {1000,4000,6000} or {1000} or {1000,4000} called ekw . These values match to a description string in another table tab: test id | name | ekw ----------------- 1 | One | {1000} 2 | Two | {1000,4000} 3 | Three | {1000,4000,6000} tab: ekwdesc id | value | desc ----------------- 1 | 1000 | Max 2 | 2000 | Tim 3 | 3000 | Rita 5 | 4000 | Sven 6 | 5000 | Tom 7 | 6000 | Bob is it possible to select these columns and print the strings?

Unable to syncdb in GeoDjango App

随声附和 提交于 2019-12-12 09:40:06
问题 I am having a real trouble in setting up spatial database and syncing it with GeoDjango. I was able to setup the spatial database as per the geodjango documentation and create a django app but when i run python manage.py sqlall world I am getting this, Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/home/smaranh/django-env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from

PostgreSQL - INSERT an array of composite type containing arrays

老子叫甜甜 提交于 2019-12-12 08:56:03
问题 I have a composite type containing arrays of TEXT, etc. I am using this inside my main table to create an array of composite type. How do I generate an INSERT command (without using the default field names of the composite type) ? Can I create a TEMPORARY TABLE with the array of composites and then insert it into the main table? For example: DROP TABLE collection; DROP TABLE book_set; DROP TYPE book; CREATE TYPE book AS ( title TEXT, authors TEXT[], extra_spare TEXT ); CREATE TEMPORARY TABLE

Dump or restore Postgresql databases without Postgis functions

…衆ロ難τιáo~ 提交于 2019-12-12 08:10:10
问题 I want to dump 4 databases from postgresql 8.4 to migrate to Postgresql 9.1. I use PostGis on the old Postgresql 8.4 with PgRouting so each database has around 1000 functions. Each time I export all databases, all functions are written in the dump. When I restore the backup file, I get some conflicts when I create an extension of postgis or pgrouting on Postgresql 9.1 Is there anyway to dump databases on 8.4 (create dbs, create schemas, create tables and data) without exporting fucntions as

How to parse xml with optional elements

你说的曾经没有我的故事 提交于 2019-12-12 07:04:13
问题 SEPA ISO XML transactions file needs to be parsed into flat table in Postgres 9.1+ in ASP:NET 4.6 MVC controller. I tried code below but this produces wrong result: endaaa tasusumma orderinr XX00221059842412 150.00 PV04131 XX00221059842412 0.38 PV04131 Since there is no EndToEnd in second row there should be null or empty text in second row orderinr column: endaaa tasusumma orderinr XX00221059842412 150.00 PV04131 XX00221059842412 0.38 null How to fix this ? Parsing can done in other ways e.q

fabric postgres password in command

自古美人都是妖i 提交于 2019-12-12 03:17:41
问题 I have a fabric script that dumps database on server. And I can use it on multiple servers with the PostgreSQL database. The command is simple: sudo("su postgres -c \"PGPASSWORD=%s pg_dump %s > /tmp/telemedia_newdb\"" % (HOST_SOURCE_DB_UPASS,HOST_SOURCE_DB)) But sometimes, Postgres does not ask for a password at all ... Will this command fail without a password prompting from Postgres? (Or I know that it will not prompt and HOST_SOURCE_DB_UPASS='' ). I want THIS code to work with or without

Postgresql inheritance and foreign key referencing parent table

女生的网名这么多〃 提交于 2019-12-12 02:55:52
问题 I already documented about this and read other users post about this on so, but in my case the referencing should be working fine: I have several tables extending one "entity" table and an "association" table referencing just "entity" table. So I'm referencing just the parent table which own every other table id. How come I get the following then? ERROR: insert or update on table "association" violates foreign key constraint "association_id1_fkey" DETAIL: Key (id1)=(1) is not present in table

Concurrent processes working on a PostgreSQL table

为君一笑 提交于 2019-12-12 02:54:36
问题 I have a simple procedure where I need to process records of a table, and ideally run multiple instances of the process without processing the same record. The way I've done this with MySQL is fairly common (although I perceive the token field to be more of a hack): Adding a couple of fields to the table: CREATE TABLE records ( id INTEGER PRIMARY KEY AUTO_INCREMENT, ...actual fields... processed_at DATETIME DEFAULT NULL, process_token TEXT DEFAULT NULL ); And then a simple processing script:

Converting between clause to joins [duplicate]

微笑、不失礼 提交于 2019-12-12 02:39:33
问题 This question already has answers here : How to use indexes for a query filtering BETWEEN two columns (2 answers) Closed 5 years ago . Need a generic sql query for joins that can run on mysql, postgres and other major DBs I have a table named autumn4.ip , I have three columns: id,start,end (all ints). How do I make a join so that I make use of BUT not by BETWEEN but by JOINS. like pseudo: select * FROM autumn.ip WHERE :number-constant >= start ORDER BY start DESC LIMIT 1; + select * FROM