Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to pipe multiple sql- and py-scripts

I have the following code copied from github gtfs_SQL_importer:

cat gtfs_tables.sql \
  <(python import_gtfs_to_sql.py path/to/gtfs/data/directory) \
  gtfs_tables_makeindexes.sql \
  vacuumer.sql \
  | psql mydbname

I tried to run this on windows and replaced the call to the UNIX-command cat by the windows equivalent type which should work similar as of is-there-replacement-for-cat-on-windows.

However when I execute that code I get some error:

The syntax for the filename, directory or filesystem is wrong.

So I tried to limit the number of piped files to only combine the call to python and the call to psql:

type <(C:/python27/python path/to/py-script.py path/to/file-argument) | psql -U myUser -d myDatabase

which results in the same error.

However when I execute the python-script alone it works as expected:

C:/python27/python path/to/py-script.py path/to/file-argument

So I assume the error results from using type in order to pipe the result of the script directly to psql.

Does anyone know the correct syntax?

EDIT: To ensure the problem is not related to a file not being found I used absolute paths for all arguments within my command except the type and the psql-command (which are both handled via the %PATH%-variable).

like image 832
MakePeaceGreatAgain Avatar asked May 28 '17 18:05

MakePeaceGreatAgain


1 Answers

Install cygwin and use unix cat on Windows.

like image 108
matt2000 Avatar answered Oct 25 '22 22:10

matt2000