hitting an issue where you hopefully can help me with: I want to import a csv file to postgres with powershell. For this have written following code:
$ConnectionString = "Driver={PostgreSQL UNICODE(x64)};Server=$SQLServer;Port=$SLQPort;Database=$SQLDB;Uid=$SQLUser;Pwd=$SQLPass;"
$connection = New-Object System.Data.ODBC.ODBCConnection
$connection.ConnectionString = $ConnectionString
$connection.Open()
$query= "copy sensorhistory from 'C:\Powershell_Scripts\Postgres\Eurogate\data\export.csv' Delimiter ',' csv header;"
$DBCmd = $connection.CreateCommand();
$DBCmd.CommandText = $query
$DBCmd.ExecuteNonQuery() | Out-Null
$DBCmd.ExecuteReader();
But I am getting the error "No such file or directory" the link is correct and already made changes to allow access to everybody, but still not working. Any help is welcome
\\$SQLServer\C$\Powershell_Scripts\Postgres\Eurogate\data\export.csvfirst?... from '\\cyberoner1sLaptop\c$\...\export.csv' ...), or copy the CSV file to the machine that hosts Postgres before executing the query.