使用pgloader将数据从sqlite3迁移到postgresql时出错

问题描述 投票:0回答:1

我有这个文件来进行迁移“migracion.load”:

LOAD DATABASE
  FROM sqlite://database.sqlite
  INTO postgresql://xxxx:xxxx@localhost:5432/db_marc

WITH include drop, create tables, create indexes, reset sequences;

当我运行“pgloader migracion.load”时

我收到此错误:

    2024-11-20T13:34:09.010631Z LOG pgloader version "3.6.7~devel"
2024-11-20T13:34:09.010631Z LOG Parsing commands from file #P"/mnt/c/Users/Juane/Desktop/fiat 900/migracion.load"
2024-11-20T13:34:09.138197Z LOG Migrating from #<SQLITE-CONNECTION sqlite:///mnt/c/Users/Juane/Desktop/fiat 900/database.sqlite {1006A14453}>
2024-11-20T13:34:09.138197Z LOG Migrating into #<PGSQL-CONNECTION pgsql://juane27@localhost:5432/db_marc {1006A14643}>
2024-11-20T13:34:09.457110Z ERROR Database error 22007: invalid input syntax for type timestamp with time zone: "STRFTIME('%Y-%m-%d %H:%M:%f', 'NOW')"
QUERY: CREATE TABLE role
(
  id        bigserial,
  name      text,
  scope     text,
  createdat timestamptz default 'STRFTIME(''%Y-%m-%d %H:%M:%f'', ''NOW'')',
  updatedat timestamptz default 'STRFTIME(''%Y-%m-%d %H:%M:%f'', ''NOW'')'
);
2024-11-20T13:34:09.457110Z FATAL Failed to create the schema, see above.
2024-11-20T13:34:09.457110Z LOG report summary reset
       table name     errors       rows      bytes      total time
-----------------  ---------  ---------  ---------  --------------
            fetch          0          0                     0.000s
  fetch meta data          0        105                     0.085s
   Create Schemas          0          0                     0.000s
 Create SQL Types          0          0                     0.011s
    Create tables          0          0                     0.000s
-----------------  ---------  ---------  ---------  --------------
-----------------  ---------  ---------  ---------  --------------

你知道我需要添加什么规则吗?或者出了什么问题?我尝试过很多事情。

postgresql sqlite pgloader
1个回答
0
投票

它告诉你

invalid input syntax for type timestamp with time zone: "STRFTIME('%Y-%m-%d %H:%M:%f', 'NOW')"

这不是时间戳的有效语法,是吗?

https://www.postgresql.org/docs/current/datatype-datetime.html

我假设 sqlite 将时间戳存储为字符串。您只需使用

CURRENT_TIMESTAMP
now()

© www.soinside.com 2019 - 2024. All rights reserved.