notes/vertica-access-via-psql.md

Psql can connect to Vertica

In order to not have to retype user, host, database, port, and of course password we suggest a simple shellscript, say setEnv.sh, containing

#!/bin/bash

export PGHOST=some.server.some.where
export PGPORT=5433
export PGDATABASE=dbname
export PGUSER=dbuser
export PGPASSWORD=somepassword

Set your appropriate values and then source it: . setEnv.sh.

$ psql -c 'select count(*) from product_dimension;'
 count 
-------
 60000
(1 row)

$

This provides an existence proof.

Similar to what we did via Python

$ psql -c 'select product_key, product_version, product_description from product_dimension limit 5' product_key | product_version | product_description -------------+-----------------+------------------------------ 1 | 1 | Brand #2 bagels 1 | 2 | Brand #1 butter 2 | 1 | Brand #6 chicken noodle soup 2 | 2 | Brand #5 golf clubs 2 | 3 | Brand #4 brandy (5 rows)

$

Create a simple SQL script:

create table sqltest (x numeric, y numeric, z numeric);
insert into sqltest values (1,2,3);
insert into sqltest values (4,5,6);
commit;

Run it:

```bash $ psql -f ex3.sql CREATE TABLE OUTPUT

1 (1 row)

INSERT OUTPUT

1 (1 row)

INSERT COMMIT $

Check it:

$ psql -c 'select * from sqltest;' x | y | z -------------------+-------------------+------------------- 1.000000000000000 | 2.000000000000000 | 3.000000000000000 4.000000000000000 | 5.000000000000000 | 6.000000000000000 (2 rows)

$



DevProgress/RVertica documentation built on May 6, 2019, 2:11 p.m.