psql - PyGreSQL Run SQL interactively -


i have greenplum database, , i'm trying create several external tables.

i'm using pygresql package interface database.

however, can't escape \i (or \dt, \du, \dv).

db.query("\i h1/ext/eng/ext_eng" + + ".sql")

pg.programmingerror: error: syntax error @ or near "\"

i've tried "\\i", " '\i' " , other combinations.

i'm not aliases can used generic clients.

you can avoid \i first reading file h1/ext/eng/ext_eng.sql python, streaming resulting sql text pygresql db.query().

as \dt, \du, , \dv - sql equivalents can see running \set echo_hidden psql prompt, issuing each see true definition. i've included result below.

\dt:

select n.nspname "schema",   c.relname "name",   case c.relkind when 'r' 'table' when 'v' 'view' when 'i' 'index' when 's' 'sequence' when 's' 'special' end "type",   pg_catalog.pg_get_userbyid(c.relowner) "owner", case c.relstorage when 'h' 'heap' when 'x' 'external' when 'a' 'append only' when 'v' 'none' when 'c' 'append columnar' when 'p' 'parquet' when 'f' 'foreign' end "storage"  pg_catalog.pg_class c      left join pg_catalog.pg_namespace n on n.oid = c.relnamespace c.relkind in ('r','') , c.relstorage in ('h', 'a', 'c', 'p','')       , n.nspname <> 'pg_catalog'       , n.nspname <> 'information_schema'       , n.nspname !~ '^pg_toast'   , pg_catalog.pg_table_is_visible(c.oid) order 1,2; 

\du:

select r.rolname, r.rolsuper, r.rolinherit,   r.rolcreaterole, r.rolcreatedb, r.rolcanlogin,   r.rolconnlimit,   array(select b.rolname         pg_catalog.pg_auth_members m         join pg_catalog.pg_roles b on (m.roleid = b.oid)         m.member = r.oid) memberof pg_catalog.pg_roles r order 1; 

\dv:

select n.nspname "schema",   c.relname "name",   case c.relkind when 'r' 'table' when 'v' 'view' when 'i' 'index' when 's' 'sequence' when 's' 'special' end "type",   pg_catalog.pg_get_userbyid(c.relowner) "owner", case c.relstorage when 'h' 'heap' when 'x' 'external' when 'a' 'append only' when 'v' 'none' when 'c' 'append columnar' when 'p' 'parquet' when 'f' 'foreign' end "storage"  pg_catalog.pg_class c      left join pg_catalog.pg_namespace n on n.oid = c.relnamespace c.relkind in ('v','') , c.relstorage in ('v','')       , n.nspname <> 'pg_catalog'       , n.nspname <> 'information_schema'       , n.nspname !~ '^pg_toast'   , pg_catalog.pg_table_is_visible(c.oid) order 1,2; 

it's not ideal, can replace \d references these code equivalents.


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -