dimitri / pgloader

Migrate to PostgreSQL in a single command!
http://pgloader.io
Other
5.45k stars 548 forks source link

ESRAP-PARSE-ERROR: At end of input #1505

Open Julienh opened 1 year ago

Julienh commented 1 year ago

Hello,

Here is my version:

pgloader version "3.6.9"
compiled with SBCL 1.4.16.debian

When I use the command line it is working:

pgloader --no-ssl-cert-verification --verbose mysql://dbtestlocal:dbtestlocal@localhost:3306/dbtest "postgresql://dbtestlocal@localhost:5432/dbtest?sslmode=allow&password=dbtestlocal"

Now I would like to CAST datetime, so I'm trying to use pgloader from a file:

LOAD DATABASE
FROM mysql://dbtestlocal:dbtestlocal@localhost:3306/dbtest 
INTO postgresql://dbtestlocal@localhost:5432/dbtest?sslmode=allow&password=dbtestlocal
CAST type datetime to timestamp drop default drop not null using zero-dates-to-null;

With the command:

pgloader --no-ssl-cert-verification pgloader.load

And I have this error:

2023-06-26T16:03:23.014000Z LOG pgloader version "3.6.7~devel"
KABOOM!
ESRAP-PARSE-ERROR: At end of input

  CAST type datetime to timestamp drop default drop not null using zero-dates-to-null;

  ^ (Line 5, Column 0, Position 255)

In context COMMAND:

While parsing COMMAND. Expected:

     the character Tab
  or the character Newline
  or the character Return
  or the character Space
  or the character & (AMPERSAND)
  or the string "--"
  or the string "/*"
  or the character ; (SEMICOLON)
  or the string "after"
  or the string "alter"
  or the string "before"
  or the string "cast"
  or the string "decoding"
  or the string "distribute"
  or the string "excluding"
  or the string "including"
  or the string "materialize"
  or the string "set"
  or the string "with"
  or <end of input>
  or anything but the character & (AMPERSAND)
An unhandled error condition has been signalled: At end of input

  CAST type datetime to timestamp drop default drop not null using zero-dates-to-null;

  ^ (Line 5, Column 0, Position 255)

In context COMMAND:

While parsing COMMAND. Expected:

     the character Tab
  or the character Newline
  or the character Return
  or the character Space
  or the character & (AMPERSAND)
  or the string "--"
  or the string "/*"
  or the character ; (SEMICOLON)
  or the string "after"
  or the string "alter"
  or the string "before"
  or the string "cast"
  or the string "decoding"
  or the string "distribute"
  or the string "excluding"
  or the string "including"
  or the string "materialize"
  or the string "set"
  or the string "with"
  or <end of input>
  or anything but the character & (AMPERSAND)

What I am doing here?

At end of input

  CAST type datetime to timestamp drop default drop not null using zero-dates-to-null;

  ^ (Line 5, Column 0, Position 255)

In context COMMAND:

While parsing COMMAND. Expected:

     the character Tab
  or the character Newline
  or the character Return
  or the character Space
  or the character & (AMPERSAND)
  or the string "--"
  or the string "/*"
  or the character ; (SEMICOLON)
  or the string "after"
  or the string "alter"
  or the string "before"
  or the string "cast"
  or the string "decoding"
  or the string "distribute"
  or the string "excluding"
  or the string "including"
  or the string "materialize"
  or the string "set"
  or the string "with"
  or <end of input>
  or anything but the character & (AMPERSAND)

Do you have any idea how can I fix it please? Thank you

Julienh commented 1 year ago

If I use the command line with the case it is working:

pgloader --no-ssl-cert-verification --verbose --cast "type datetime to timestamp drop default drop not null using zero-dates-to-null" mysql://dbtestlocal:dbtestlocal@localhost:3306/dbtest "postgresql://dbtestlocal@localhost:5432/dbtest?sslmode=allow&password=dbtestlocal"
svantevonerichsen6906 commented 1 year ago

The command doesn't parse, but I'm not sure why. It seems that when you leave off the &password=dbtestlocal part, it would parse.

According to the documentation in docs/command.rst, the password should be set in the user spec before the host (...user:passwd@host...), or through the environment variable PGPASSWORD, or through a .pgpass file. (I believe the latter two ways should be preferable from a security standpoint, btw.)