我正在尝试读一个表,修改一个列,然后写到另一个表。我遵循了可用的文档并运行了以下代码。它不会给出任何错误,但任务也不会执行。
我尝试删除转换步骤,然后写入信息。
import sqlalchemy
import bonobo
import bonobo_sqlalchemy
def get_services():
return {
'sql_alchemy.engine': sqlalchemy.create_engine('postgresql://postgres:password@localhost:5432/postgres')
}
def transform(*row):
new_row = row[0]+1, row[1]
yield new_row
def get_graph(**options):
graph = bonobo.Graph()
graph.add_chain(bonobo_sqlalchemy.Select('SELECT * FROM users', engine='sql_alchemy.engine')
,
transform,
bonobo_sqlalchemy.InsertOrUpdate(table_name='table_1', engine='sql_alchemy.engine'),
)
return graph
# The __main__ block actually execute the graph.
if __name__ == '__main__':
parser = bonobo.get_argument_parser()
with bonobo.parse_args(parser) as options:
bonobo.run(get_graph(**options), services=get_services(**options))输出:- Select in=1 out=6 done - format_for_db in=6 out=6 done - InsertOrUpdate in=6 out=6 done
发布于 2019-05-09 17:37:18
它在如下所示的字典生成时工作,
yield {"id": row[0], "text": row[1], "count":row[2]}
与链中的bonobo.UnpackItems(0)节点进行转换后。
https://stackoverflow.com/questions/56017305
复制相似问题