我正在使用 Jupyter 笔记本来处理一些带有 postgresql 的数据库我有以下实例:
import pandas as pd
import (other packages)
conn_string= % I can't show this, but this is ok
conn = psycopg2.connect(conn_string)
cursor=conn.cursor
query= """ copy (select col1,col2 from Table where col3=a_parameter
and col4=b_parameter) to '/tmp/test.csv' with csv """
pd.read_sql(query,conn)
但我得到了这个错误:
**ProgrammingError: syntax error at or near "("
LINE 1: COPY (select col1,col2 from Table where col3...**
^
为什么复制句子有错误? 我正在使用 Postresql 8.0.2