【问题标题】:Python - Luigi - Copy to PostgresPython - Luigi - 复制到 Postgres
【发布时间】:2017-05-14 20:37:40
【问题描述】:

我想定义一个 Luigi 任务,它将在 AWS 的 Postgres 数据库中创建一个表。我尝试了不同的导入,例如:

import luigi.contrib.postgres.CopyToTable
from luigi.contrib.postgres import CopyToTable
import luigi.contrib.postgres
from luigi.contrib import postgres
import luigi.postgres ( i thing this is depreceated)

我收到不同的错误,但总是相似,例如:

AttributeError: module 'luigi.contrib' has no attribute 'postgres'
ModuleNotFoundError: No module named 'luigi.contrib.postgres'

有谁知道问题出在哪里?我的任务是下一个:

class InsertToRDS(luigi.contrib.postgres.CopyToTable):

    def requires(self):
        return ReShape()

    host = ""
    database = ""
    user = ""
    password = ""  # ;)
    table = "extropy"

    columns = [("author", "TEXT"),
               ("file_id", "TEXT"),
               ("year.month_x", "DATE"),
               ("subject", "TEXT"),
               ("subject", "TEXT"),
               ("file_timestamp", "TEXT"),
               ("mail_content", "TEXT"),
               ("next_message", "TEXT"),
               ("prev_message", "TEXT"),
               ("year.month_y", "DATE"),]

提前致谢!

【问题讨论】:

  • think*(第 5 行 - 第一个代码块)

标签: python postgresql amazon rds luigi


【解决方案1】:
from luigi.contrib.postgres import CopyToTable

是正确的语法,然后你可以跟进...

class InsertToRDS(CopyToTable):

您确定 luigi 安装正确吗?在命令行检查输出:

pip show luigi

如果出现正确的版本,请在命令行运行 python 并再次尝试第一个导入行。如果它在那里工作,那么你运行程序的方式就很糟糕。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-11-09
    • 1970-01-01
    • 2016-10-18
    • 1970-01-01
    • 2020-07-19
    • 2011-11-09
    • 1970-01-01
    相关资源
    最近更新 更多