我使用python代码返回单个列的数据。但是,当我打印结果时,每一行将包含(\t value)
。但是我想将所有内容都组合到Python中的一行中(我们可以通过Psql来完成,但是我试图使其与Python一起使用。
我的代码:
import psycopg2
def get_pg_con():
return psycopg2.connect(dbname='dev',host='POSTGRESIP',user='USER',password='PASS',port='5432')
def handler(handler,context):
print('test')
conn = get_pg_con()
cur = conn.cursor()
copy_command="""
select myval from mytbl; """
cur.execute(copy_command)
result = cur.fetchall()
results = ''.join(map(str,result))
print(results)
输出
(this is,)(\t my new,)(values)
预期产量
this is,my new,values