首先获取链接:
import dolphindb as ddb
from loguru import logger
def get_dolphin_session():
"""获取dolphinDB的session"""
dolphin_config = {
"host": "127.0.0.1",
"port": 13900,
"username": "admin",
"password": "123456",
}
s = ddb.session()
_result = s.connect(dolphin_config['host'], dolphin_config['port'], dolphin_config['username'],
dolphin_config['password'])
if not _result:
logger.error("DolphinDB 数据库无法连接!!")
return None
return s
读取某个表的列名称:
dolphin_s = get_dolphin_session()
exist_table= dolphin_s.loadTable(tableName="base_info", dbPath="dfs://my_db") # 指定哪个数据库的哪个数据表
print(exist_table.colNames) # 这个就是列名称