气流中Postgres Hook的CSV_Expert不会在没有错误的情况下写任何东西
我想通过气流将CSV文件写入Postgres的表格。 我遇到了这条气流表示挂钩已经具有用于CSV导出的内置函数。 并使用此 thread 如何使用它。 我有一个Python操作员,其Python_collable如下:
def copy_expert_csv():
hook = PostgresHook(postgres_conn_id='warehouse',host='data-warehouse',
database='datalake',
user='root',
password='root',
port=9999)
with hook.get_conn() as connection:
hook.copy_expert("""COPY datalake.public.wcc_users FROM stdin WITH CSV HEADER
DELIMITER as ',' """,
'includes/cleaned_data/wwc/' + str(date.today()) + '_wwc_cleaned ')
connection.commit()
并且我的数据库中也没有错误日志:
materials-data-warehouse-1 | 2022-04-29 17:43:01.942 UTC [198] STATEMENT: COPY datalake.public.wcc_users FROM STDIN WITH (FORMAT CSV) HEADER
我的文件约为1000行。但是,当我从表中选择时,插入了0行。
表中的列命名与文件不同,并且两个列也具有日期和时间戳数据类型,而不是文本。可以是原因吗?那为什么不丢任何错误呢?
I want to write a CSV file to a table in Postgres via Airflow.
I came across this Airflow documentation denoting that the hook already has a builtin function for CSV export.
And used this thread on how to use it.
I have a python operator whose python_callable is as follows:
def copy_expert_csv():
hook = PostgresHook(postgres_conn_id='warehouse',host='data-warehouse',
database='datalake',
user='root',
password='root',
port=9999)
with hook.get_conn() as connection:
hook.copy_expert("""COPY datalake.public.wcc_users FROM stdin WITH CSV HEADER
DELIMITER as ',' """,
'includes/cleaned_data/wwc/' + str(date.today()) + '_wwc_cleaned ')
connection.commit()
The task finishes successfully as shown in the image.
:
And there is no error logs on my database either:
materials-data-warehouse-1 | 2022-04-29 17:43:01.942 UTC [198] STATEMENT: COPY datalake.public.wcc_users FROM STDIN WITH (FORMAT CSV) HEADER
My file has around 1000 rows. However, when I select from my table, there are 0 rows inserted.
The column naming in table are different from the file and also 2 columns have date and timestamp datatypes rather than text. Can it be the cause? Then why no errors are thrown?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来表的定义不正确。这不会带来任何错误,但也什么也没有插入。
Seems that table definition was incorrect. This throws no errors but inserts nothing either.