psql

python 2.6 subprocess enter psql password C shell

家住魔仙堡 提交于 2019-12-12 05:49:11
问题 I am not able to install any additional modules on an AIX server I am scripting on. It has Python 2.6.2 installed and basically I am trying to run the below command psql -c "select * from cms_agprm;" -o u350932.txt -d tctmsv80 -U tctmsv80 Now I have done some goggling and found a few different recommendation on how to do this. None with much success. I'm also a little paranoid because I am dealing with processes and want to make sure that i get things right in this script otherwise things

Is there a way to toggle expanded table formatting mode in PrestoDB cli?

£可爱£侵袭症+ 提交于 2019-12-12 04:55:59
问题 I am querying S3 buckets from PrestoDB cli. I have a small display and I would love to have an equivalent command for \x auto in psql , which allows you to toggle expanded table formatting mode: Before: id | time | humanize_time | value ----+-------+---------------------------------+------- 1 | 09:30 | Early Morning - (9.30 am) | 570 2 | 11:30 | Late Morning - (11.30 am) | 690 3 | 13:30 | Early Afternoon - (1.30pm) | 810 4 | 15:30 | Late Afternoon - (3.30 pm) | 930 (4 rows) After: -[ RECORD 1

Is there a way to insert an accentuated letter in psql?

青春壹個敷衍的年華 提交于 2019-12-12 04:34:39
问题 I'm trying to insert an accentuated letter with PostgreSQL (9.6), but I don't manage to do it... If I copy/paste a query, it removes the accentuated letters, if I try to insert them directly, it does not print anything. What can I do? 回答1: It looks to be shell environment problem, Please try applying solution from https://unix.stackexchange.com/questions/98185/bash-environment-pasting-strings-with-special-characters pgcli I suppose is python and probably has additional libraries 来源: https:/

Is there a correct way to parse output in Bash from a command?

妖精的绣舞 提交于 2019-12-12 04:25:34
问题 I'm using psql to run a few commands, where the last one is something similar to: select max(id) from tablename . I'm trying to get the id of the last row inserted. It returns the correct value (7) in this scenario. Begin Informatica Script SET INSERT 0 1 max ----- 7 (1 row) Redshift Delta copy completed at: 04/10/17 17:45:21 END However, I'm trying to parse it and have no idea what to do... Is there a way to limit the output to just the value of 7 ? If not, how do I grab just the number?

How do I import a file of SQL commands to PostgreSQL?

倖福魔咒の 提交于 2019-12-12 02:52:04
问题 I'm running this command from PostgreSQL 9.4 on Windows 8.1: psql -d dbname -f filenameincurrentdirectory.sql The sql file has, for example, these commands: INSERT INTO general_lookups ("name", "old_id") VALUES ('Open', 1); INSERT INTO general_lookups ("name", "old_id") VALUES ('Closed', 2);` When I run the psql command, I get this error message: psql:filenameincurrentdirectory.sql:1: ERROR: syntax error at or near "ÿ_I0811a2h1" LINE 1: ÿ_I0811a2h1 ru How do I import a file of SQL commands

Migrating from odoo 8 to 9 fails with error msg: column “store” of relation “ir_model_fields” does not exist

守給你的承諾、 提交于 2019-12-11 19:28:52
问题 Tried with python migrate.py --config=/etc/openerp/openerp-server.conf --database=test_data --run-migrations=9.0 Outcome: Failed, fallback on creating empty database + loading a dump running migration for 9.0 Log file/ migration.log /: UndefinedColumn: column ir_attachment.res_field does not exist Could anybody give a hint or help? Much appreciated. 来源: https://stackoverflow.com/questions/56470582/migrating-from-odoo-8-to-9-fails-with-error-msg-column-store-of-relation-ir

How to list databases owned by rolename in postgresql

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 16:16:36
问题 The code i tried in bash executed by root. #!/bin/bash su - postgres <<EOF1 F="$(psql -d postgres --tuples-only -P format=unaligned -c "SELECT datname FROM pg_database JOIN pg_authid ON pg_database.datdba = pg_authid.oid WHERE rolname = 'username'")" EOF1 echo $F It gives output as ERROR: permission denied for relation pg_authid But when i try su - postgres <<EOF1 psql -d postgres --tuples-only -P format=unaligned -c "SELECT datname FROM pg_database JOIN pg_authid ON pg_database.datdba = pg

How to find pairs of events with postgres?

跟風遠走 提交于 2019-12-11 15:46:51
问题 I have an events table: ts | user | reason ----------------------------+--------+-------- 2018-06-01 10:44:15.52+01 | 359999 | START 2018-06-01 10:44:29.521+01 | 359999 | STOP 2018-06-01 10:44:43.52+01 | 359998 | START 2018-06-01 10:44:55.52+01 | 359999 | START 2018-06-01 10:44:59.521+01 | 359998 | STOP 2018-06-01 10:45:07.52+01 | 359999 | STOP 2018-06-01 10:46:16.52+01 | 359999 | START And I want to find the pairs of events: user | start | stop --------+----------------------------+---------

How to fire VACUUM command using shell script in postgres

对着背影说爱祢 提交于 2019-12-11 14:50:12
问题 Here is my shell script #!/bin/bash psql --host=127.0.0.1 --port=5432 --dbname=SIEM --username=dbauser vacuumdb --analyze --verbose --table 'vuln' SIEM but its not working fine and gives error as: linux-lxh4:/home/gaurav # ./script.sh psql (9.2.5) Type "help" for help. SIEM=# \q vacuumdb: could not connect to database root: FATAL: Peer authentication failed for user "root" Edit1:I used this code : psql --host=127.0.0.1 --port=5432 --dbname=SIEM --username=dbauser VACUUM FULL VERBOSE vuln And

How to create sequence using starting value from query?

别说谁变了你拦得住时间么 提交于 2019-12-11 13:23:54
问题 In database migration script (psql) I want to create sequence starting from certain value queried from table, like: CREATE SEQUENCE book_id_seq START ( SELECT MAX(id) + 1 FROM book.book ); or tried to set \set start (SELECT MAX(id) + 1 FROM book.book) to use variable like: CREATE SEQUENCE book_id_seq START :'start'; But using \set did not inerpret the query. Another way setting variable did not work also start := SELECT MAX(id) + 1 FROM book.book; gave error: ERROR: syntax error at or near ":