0

i have 2 files. 1) is txt.sql and 2) is post.html . i am try to insert in to my postgresql Table using .sql script. used windows cmd, Powershell and my IDE(vscode as well).

my script code here txt.sql

\set content `cat post.html`
INSERT INTO posts (
    post_name,
    post_date,
    title,
    body
)
VALUES(
    'hello_world',
    '2021-12-20',
    'Hello World',
    :'content'
);

and my post.html code here

<h1>
    Hello World!
</h1>
<p>
    Thank you for visiting my blog.
</p>

when i ran below command against myapp database.

myapp-# \i txt.sql 

got below results and inserted data with out content

'cat' is not recognized as an internal or external command, operable program or batch file. INSERT 0 1

i belive cat shell command only for unix and not for windows. can you help me with other solution to read data from file and insert in to table column in windows psql.

sdandamud1
  • 97
  • 2

1 Answers1

0

The Windows equivalent of cat is called type.

From the horse's mouth:

type is a built in command which displays the contents of a text file.

BigSmoke
  • 406
  • 4
  • 14