psql

How can I connect to a postgreSQL database into Apache Spark using scala?

会有一股神秘感。 提交于 2019-12-17 10:15:15
问题 I want to know how can I do following things in scala? Connect to a postgreSQL database using Spark scala. Write SQL queries like SELECT , UPDATE etc. to modify a table in that database. I know to do it using scala but how to import the connector jar of psql scala into sbt while packaging it? 回答1: Our goal is to run parallel SQL queries from the Spark workers. Build setup Add the connector and JDBC to the libraryDependencies in build.sbt . I've only tried this with MySQL, so I'll use that in

Postgresql: Scripting psql execution with password

情到浓时终转凉″ 提交于 2019-12-17 05:36:00
问题 How can I call psql so that it doesn't prompt for a password ? This is what I have: psql -Umyuser < myscript.sql However, I couldn't find the argument that passes the password, and so psql always prompts for it. 回答1: There are several ways to authenticate to PostgreSQL. You may wish to investigate alternatives to password authentication at https://www.postgresql.org/docs/current/static/client-authentication.html. To answer your question, there are a few ways provide a password for password

Postgresql: Scripting psql execution with password

断了今生、忘了曾经 提交于 2019-12-17 05:35:28
问题 How can I call psql so that it doesn't prompt for a password ? This is what I have: psql -Umyuser < myscript.sql However, I couldn't find the argument that passes the password, and so psql always prompts for it. 回答1: There are several ways to authenticate to PostgreSQL. You may wish to investigate alternatives to password authentication at https://www.postgresql.org/docs/current/static/client-authentication.html. To answer your question, there are a few ways provide a password for password

psql: error while loading shared libraries: libpq.so.5: cannot open shared object file: No such file or directory

岁酱吖の 提交于 2019-12-14 04:09:54
问题 I have the psql path in my path variable. crontab path is usr:/usr/bin:/bin I add all the user directories and then execute the cron job. Default PATH for usr:/usr/bin:/bin user is:gpadmin PATH for usr:/usr/bin:/bin:/usr/local/greenplum-db/./bin:/usr/local/greenplum-db/./ext/python/bin:/home/gpadmin/anaconda3/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/home/gpadmin/bin My script is as below (executed by crontab): #!/bin/bash # Usage : bash RR_load.sh echo "Loading the data into

Psql COPY with constraint fails

萝らか妹 提交于 2019-12-13 16:01:38
问题 I have a table like this in the server: CREATE TABLE example_table ( id BIGSERIAL PRIMARY KEY, name VARCHAR(70) NOT NULL, status VARCHAR(70) NOT NULL CONSTRAINT status_enum CHECK (status IN ('old', 'new')), UNIQUE (id, name) ); And I have an SQL file, example.sql. The first line contain a header: name_of_class,status 'CLASSNAME','old'; And I try to run a psql \copy to google server: PGPASSWORD=password psql -d database --username username --port 5432 --host 11.111.111 << EOF BEGIN; \copy

run psql query in bash

只谈情不闲聊 提交于 2019-12-13 07:43:21
问题 I am new in bash and psql, I want to write a bash code that login a server the connect to psql database do a select query and then return the output. the set up I have as follow. server named dbs, it has psql install and running. database name = dname, user= tester passwrod = 1234 in the database there is table called node_info it has 3 colons ip, mac, connection_time. I want to run following query select ip, connection_time from node_info where ip=10.10.10.2; Any tips how to write a shell

restore single table dump from a sql file

让人想犯罪 __ 提交于 2019-12-13 06:27:04
问题 I have full dump of sql file like dump_full.sql of size 1.3GB And it has some tables like dancing_core_spice dancing_sea_beast forde_clear_one forde_super_now Now what i want is need to restore/fetch/dump only data of these tables from dump_full.sql file psql -U postgres --table=dancing_core_spice dump_full.sql > dancing_core_spice.sql i tried the above command but it is not working So can anyone please let me know how to take the dump of only single table from the sql file(full dump) 回答1:

Substract 2 hstore, You might need to add explicit type casts

家住魔仙堡 提交于 2019-12-13 05:21:11
问题 Documentation for postgres has hstore - hstore which delete matching pairs from left operand. Installed postgres extensions. When I try select public.hstore('"x"=>"30", "y"=>"c"') - public.hstore('"x"=>"30","y"=>"fred"') is error-ing with following ERROR: operator does not exist: public.hstore - public.hstore LINE 3: select public.hstore('"x"=>"30", "y"=>"c"') - public.hstore... ^ HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts. 回答1:

PSQL: SSL error: unknown protocol

社会主义新天地 提交于 2019-12-12 14:59:17
问题 all. I have a new Ubuntu 17.04 server setup. I can access it through ssh successfully. Also, I have a postgresql database installed. It is already configured to accept remote connections through the following configurations: pg_hba.conf host all all 0.0.0.0/0 md5 postgresql.conf listen_addresses = '*' But when I try to access the database from my computer, I get the following error: psql -h [SERVER_IP] -d db_production -U dbuser psql: SSL error: unknown protocol expected authentication

psql: permission denied for database “dbname” (“User does not have CONNECT privilege.”) / “unrecognized role option 'connect'”

橙三吉。 提交于 2019-12-12 07:26:18
问题 when I try to login to my database with psql, doing this: psql dbname --username=qgis --password >>(prompts for password, entered password) psql: FATAL: permission denied for database "gisdatabase" DETAIL: User does not have CONNECT privilege. I've searched around on Google for information on this simple issue but haven't found anyone directly talking about this. I've tried doing this: psql dbname >>ALTER ROLE qgis WITH CONNECT; But got this error: ERROR: unrecognized role option "connect" So