1

Using Python 3.8.1 code, I unzipped the distribution of postgresql12 in a specific folder of root C, inside the code it creates two other folders, data and log. In the code I write the following line to set up a first database:

subP = subprocess.run([link_initdb, "-U NewDataBase", "-A AlphaBeta", "-E utf8", "-D C:\\Database\\pgsql\\data"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="utf-8")

But I get the following error message: ubP.stderr: initdb: error: could not create directory " C:": Invalid argument

I don't know what I'm wrong!

Wolverine
  • 11
  • 1

1 Answers1

0

For whatever reason there should be no space between -D and the filename.

To solve it you can use:

subP = subprocess.run([
        link_initdb,
        "-U postgres",
        "-A password",
        "-E utf8",
        "--pgdata=C:\Database\pgsql\data",
    ],
    shell=True,
)
bdoubleu
  • 5,568
  • 2
  • 20
  • 53