Re: psql show me the : and ask user input, when running one sql file

From: arden liu <ardenbook(at)gmail(dot)com>
To: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: psql show me the : and ask user input, when running one sql file
Date: 2020-04-05 17:32:09
Message-ID: CAK0KdkmL4xAwdK8CR8HeZkD5k-T8r3NTTO_pLCDZqihu=zX8kQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi Adrian,
When I use the following java to run the same command, which does not ask
me any input. Maybe bash and java launch another process differently.
-------------------------------------
String command = "/usr/bin/psql postgresql://" +userName + ":" + password
+"@"+ host + ":" + port + "/xbrlam -f /tmp/xbrlPublicPostgresDB.ddl";
try {
Process process = Runtime.getRuntime().exec(command);
StreamGobbler streamGobbler = new StreamGobbler(process.getInputStream(),
System.out::println);
Executors.newSingleThreadExecutor().submit(streamGobbler);

int exitValue = process.waitFor();
if (exitValue == 0) {
System.out.println("XBRL-US db is ready.");
} else {
throw new RuntimeException("XBRL-US db wrong");
}
} catch (Exception e) {
throw new RuntimeException(e);
}

On Sun., Apr. 5, 2020, 12:47 p.m. Adrian Klaver, <adrian(dot)klaver(at)aklaver(dot)com>
wrote:

> On 4/5/20 9:46 AM, Adrian Klaver wrote:
> > On 4/5/20 5:50 AM, arden liu wrote:
> >> I am using psql to run this sql
> >> file(
> https://github.com/Arelle/Arelle/blob/master/arelle/plugin/xbrlDB/sql/public/xbrlPublicPostgresDB.ddl)
>
> >>
> >> here is my command:
> >> /usr/bin/psql postgresql://db_user:dbpassword(at)localhost:5432/my_db -f
> >> /tmp/xbrlPublicPostgresDB.ddl
> >> I do not know why it show me the : , which is asking me to input
> >> something.
> >> Can someone help me?
> >
> > Well I ran the file(basically a modified dump file) and what I found is
> it:
> >
> > 1) Hung on:
> >
> > INSERT INTO industry (industry_id, industry_classification,
> > industry_code, industry_description, depth, parent_id) VALUES
> > ...
> > RETURNING industry_id;
> >
> > INSERT 0 4333
> >
> > and
> >
> > INSERT INTO industry_level (industry_level_id, industry_classification,
> > ancestor_id, ancestor_code, ancestor_depth, descendant_id,
> > descendant_code, descendant_depth) VALUES
> > ...
> > RETURNING industry_level_id;
> >
> > INSERT 0 9326
> >
> > 2) It did not hang on:
> >
> > INSERT INTO industry_structure (industry_structure_id,
> > industry_classification, depth, level_name) VALUES
> > ...
> > RETURNING industry_structure_id;
> >
> > INSERT 0 13
> >
> > 3) For the hung cases all the INSERTS completed, I just needed to hit
> > any key to get the next INSERT statement to kick off.
> >
> > 4) I don't see anything wrong the statements, so I am wondering if it is
> > a shell issue?
>
>
> Hit Enter too soon.
>
> 5) All the other objects in the file where created.
>
> >
> >
> >
> >> Thanks.
> >> Arden
> >
> >
>
>
> --
> Adrian Klaver
> adrian(dot)klaver(at)aklaver(dot)com
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message arden liu 2020-04-05 17:51:34 Re: psql show me the : and ask user input, when running one sql file
Previous Message arden liu 2020-04-05 17:30:26 Re: psql show me the : and ask user input, when running one sql file