Thread: Re: load fom csv

Re: load fom csv

From
Adrian Klaver
Date:
On 9/17/24 08:13, Andy Hartman wrote:
> Still when I try to run from my powershell script it hangs...
> 

And the Postgres log shows?

-- 
Adrian Klaver
adrian.klaver@aklaver.com




Re: load fom csv

From
Andy Hartman
Date:
I don't see anything in LOG

On Tue, Sep 17, 2024 at 11:23 AM Adrian Klaver <adrian.klaver@aklaver.com> wrote:
On 9/17/24 08:13, Andy Hartman wrote:
> Still when I try to run from my powershell script it hangs...
>

And the Postgres log shows?

--
Adrian Klaver
adrian.klaver@aklaver.com

Re: load fom csv

From
Adrian Klaver
Date:
On 9/17/24 08:35, Andy Hartman wrote:
> I don't see anything in LOG

1) Are you logging connections/disconnection per?:

https://www.postgresql.org/docs/current/runtime-config-logging.html#RUNTIME-CONFIG-LOGGING-WHAT

If not do so as it will show you if a connection is being attempted.

2) Do the commands work when run in psql or supplied directly to psql 
outside of PowerShell?


> 
> On Tue, Sep 17, 2024 at 11:23 AM Adrian Klaver 
> <adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>> wrote:
> 
>     On 9/17/24 08:13, Andy Hartman wrote:
>      > Still when I try to run from my powershell script it hangs...
>      >
> 
>     And the Postgres log shows?
> 
>     -- 
>     Adrian Klaver
>     adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>
> 

-- 
Adrian Klaver
adrian.klaver@aklaver.com




Re: load fom csv

From
Andy Hartman
Date:
The command work outside of powershell  yes

On Tue, Sep 17, 2024 at 11:39 AM Adrian Klaver <adrian.klaver@aklaver.com> wrote:
On 9/17/24 08:35, Andy Hartman wrote:
> I don't see anything in LOG

1) Are you logging connections/disconnection per?:

https://www.postgresql.org/docs/current/runtime-config-logging.html#RUNTIME-CONFIG-LOGGING-WHAT

If not do so as it will show you if a connection is being attempted.

2) Do the commands work when run in psql or supplied directly to psql
outside of PowerShell?


>
> On Tue, Sep 17, 2024 at 11:23 AM Adrian Klaver
> <adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>> wrote:
>
>     On 9/17/24 08:13, Andy Hartman wrote:
>      > Still when I try to run from my powershell script it hangs...
>      >
>
>     And the Postgres log shows?
>
>     --
>     Adrian Klaver
>     adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>
>

--
Adrian Klaver
adrian.klaver@aklaver.com

Re: load fom csv

From
Adrian Klaver
Date:
On 9/17/24 09:21, Andy Hartman wrote:
> The command work outside of powershell  yes

Then you are going to need to use whatever debugging tools PowerShell 
has available to step through the script to figure out where the problem is.


-- 
Adrian Klaver
adrian.klaver@aklaver.com




Re: load fom csv

From
Rob Sargent
Date:

> On Sep 17, 2024, at 12:25 PM, Adrian Klaver <adrian.klaver@aklaver.com> wrote:
>
> On 9/17/24 09:21, Andy Hartman wrote:
>> The command work outside of powershell  yes
>
> Then you are going to need to use whatever debugging tools PowerShell has available to step through the script to
figureout where the problem is. 
>
>

Visual Studio can run/debug PS 1 files. I am not at my desk but have done ps1 oneliner queries against mssql

Suggest echoing ALL vars used in psql command

>
>



Re: load fom csv

From
Andy Hartman
Date:
I'll echo vars and see if something looks strange.

THanks.

On Tue, Sep 17, 2024 at 3:46 PM Rob Sargent <robjsargent@gmail.com> wrote:


> On Sep 17, 2024, at 12:25 PM, Adrian Klaver <adrian.klaver@aklaver.com> wrote:
>
> On 9/17/24 09:21, Andy Hartman wrote:
>> The command work outside of powershell  yes
>
> Then you are going to need to use whatever debugging tools PowerShell has available to step through the script to figure out where the problem is.
>
>

Visual Studio can run/debug PS 1 files. I am not at my desk but have done ps1 oneliner queries against mssql

Suggest echoing ALL vars used in psql command

>
>

Re: load fom csv

From
Andy Hartman
Date:
psql -h $pgServer -d $pgDatabase -U $pgUser -c $copyCommand 

I'm wondering if it's waiting on P/w ?

Thanks.

On Tue, Sep 17, 2024 at 7:10 PM Andy Hartman <hartman60home@gmail.com> wrote:
I'll echo vars and see if something looks strange.

THanks.

On Tue, Sep 17, 2024 at 3:46 PM Rob Sargent <robjsargent@gmail.com> wrote:


> On Sep 17, 2024, at 12:25 PM, Adrian Klaver <adrian.klaver@aklaver.com> wrote:
>
> On 9/17/24 09:21, Andy Hartman wrote:
>> The command work outside of powershell  yes
>
> Then you are going to need to use whatever debugging tools PowerShell has available to step through the script to figure out where the problem is.
>
>

Visual Studio can run/debug PS 1 files. I am not at my desk but have done ps1 oneliner queries against mssql

Suggest echoing ALL vars used in psql command

>
>

Re: load fom csv

From
Adrian Klaver
Date:
On 9/18/24 06:29, Rob Sargent wrote:
> 
> 
>> On Sep 18, 2024, at 6:39 AM, Andy Hartman <hartman60home@gmail.com> wrote:
>>
>> 
>> psql -h $pgServer -d $pgDatabase -U $pgUser -c $copyCommand
>>
>> I'm wondering if it's waiting on P/w ?

In a previous post I suggested:

"
To work through this you need to try what I call the crawl/walk/run 
process. In this case that is:

1) Crawl. Connect using psql and run the \copy in it with hard coded values.

2) Walk. Use psql with the -c argument and supply the command again with
hard coded values

3) Run. Then use PowerShell and do the variable substitution.
"

Did you do this with the same command at each stage? If so at either 1) 
or 2) where you asked for a password?

In a later posted I asked:

"1) Are you logging connections/disconnection per?:


https://www.postgresql.org/docs/current/runtime-config-logging.html#RUNTIME-CONFIG-LOGGING-WHAT


If not do so as it will show you if a connection is being attempted.
"

Did you enable connection logging?

Did you look at the Postgres log?

If both the answers are yes you should see something like the below in 
case of password authentication:

2024-09-18 07:47:38.692 PDT [8090] [unknown]@[unknown] LOG:  connection 
received: host=127.0.0.1 port=44840
2024-09-18 07:47:42.410 PDT [8095] [unknown]@[unknown] LOG:  connection 
received: host=127.0.0.1 port=44848
2024-09-18 07:47:42.414 PDT [8095] aklaver@test LOG:  connection 
authenticated: identity="aklaver" method=md5 
(/etc/postgresql/16/main/pg_hba.conf:125)
2024-09-18 07:47:42.414 PDT [8095] aklaver@test LOG:  connection 
authorized: user=aklaver database=test application_name=psql SSL enabled 
(protocol=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384, bits=256)


>>
>> Thanks.
> 
> Very likely.  Can you show the authentication
> mechanisms used (pg_hba)?
>>
>> On Tue, Sep 17, 2024 at 7:10 PM Andy Hartman <hartman60home@gmail.com 
>> <mailto:hartman60home@gmail.com>> wrote:
>>
>>     I'll echo vars and see if something looks strange.
>>
>>     THanks.
>>
>>     On Tue, Sep 17, 2024 at 3:46 PM Rob Sargent <robjsargent@gmail.com
>>     <mailto:robjsargent@gmail.com>> wrote:
>>
>>
>>
>>         > On Sep 17, 2024, at 12:25 PM, Adrian Klaver
>>         <adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>>
>>         wrote:
>>         >
>>         > On 9/17/24 09:21, Andy Hartman wrote:
>>         >> The command work outside of powershell  yes
>>         >
>>         > Then you are going to need to use whatever debugging tools
>>         PowerShell has available to step through the script to figure
>>         out where the problem is.
>>         >
>>         >
>>
>>         Visual Studio can run/debug PS 1 files. I am not at my desk
>>         but have done ps1 oneliner queries against mssql
>>
>>         Suggest echoing ALL vars used in psql command
>>
>>         >
>>         >
>>

-- 
Adrian Klaver
adrian.klaver@aklaver.com