2017-05-14 29 views
0

我想定義一個Luigi任務,它將在AWS中的Postgres數據庫中創建一個表。我已經嘗試了不同的進口,如:Python - Luigi - 複製到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"),] 

在此先感謝!

+0

想*(第5行 - 第一塊代碼) – marz

回答

1
from luigi.contrib.postgres import CopyToTable 

是正確的語法,然後你可以跟進......

class InsertToRDS(CopyToTable): 

你肯定路易吉安裝是否正確?在命令行來檢查的輸出:

pip show luigi 

如果有合適的版本出現時,運行python在命令行,並再次嘗試首次進口線。如果它在那裏工作,那麼你運行程序的方式就會受到束縛。