Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 使用asyncpg读取PostgreSQL表_Python 3.x_Postgresql_Dataframe_Asyncpg - Fatal编程技术网

Python 3.x 使用asyncpg读取PostgreSQL表

Python 3.x 使用asyncpg读取PostgreSQL表,python-3.x,postgresql,dataframe,asyncpg,Python 3.x,Postgresql,Dataframe,Asyncpg,我知道如何使用psycopg2、sqlalchemy在远程服务器上读取PostgreSQL表,dask,但我对阅读表格的处理时间不满意,并开始研究更快的替代方案,我发现asyncpg比所有程序都快7倍,但与上面提到的大量示例库相比,asyncpg的文档非常差 我的问题是:如何高效地读取PostgreSQL表 我尝试了以下方法: import asyncio import asyncpg import pandas as pd from sshtunnel import SSHTunnelFor

我知道如何使用psycopg2、sqlalchemy在远程服务器上读取PostgreSQL表,dask,但我对阅读表格的处理时间不满意,并开始研究更快的替代方案,我发现asyncpg比所有程序都快7倍,但与上面提到的大量示例库相比,asyncpg的文档非常差

我的问题是:如何高效地读取PostgreSQL表

我尝试了以下方法:

import asyncio
import asyncpg
import pandas as pd

from sshtunnel import SSHTunnelForwarder #Allow connection with SSH like PuttY connection
from sshtunnel import SSHTunnelForwarder, create_logger #Allow to follow the processes running

SSHTunnelForwarder(('IP_detail', Port_number),
        ssh_private_key=r'path_to_the_ssh_key_in_my_computer',

        ssh_username="username",
        #ssh_password="password", 
        remote_bind_address=('localhost', port_number),
        local_bind_address=('localhost', port_number),
        logger=create_logger(loglevel=1) #Makes processes being ran displayed
                           )

conn = await asyncpg.connect(user='username', password='password',
                                 database='database_name', host='127.0.0.1', port='port')


values = await conn.fetch('''SELECT * FROM table_name''')

values=pd.DataFrame(values)
values
通过上面的代码,我得到了PostgreSQL表中每个列的所有行值,但不显示列名,它显示列编号而不是它们的专有名称。
如何更正此问题?

使用dictvalues查看记录和有效负载的键值对

对不起,我不明白您的提示。你能再详细一点吗?