python-3.x - 使用python从直线记录计数
问题描述
我正在尝试使用 python 从直线获取记录计数,我收到错误 PermissionError: [Errno 13] Permission denied: "beeline -u ${beecon} -e 'select count(*) from dbname.tableName where signInDate = 20210315 '; $ {beecon} 是Linux中的全局变量,它指的是连接细节。如果我直接在Linux中使用它,如下命令,我得到正确的记录计数
beeline -u ${beecon} -e 'select count(*) from dbname.tableName where signInDate = 20210315';
我希望使用 Python 获得相同的输出,我的代码:
import os
import subprocess
command = "beeline -u ${beecon} -e 'select count(*) from dbname.tableName where signInDate = 20210315';"
countresult = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
countresult.wait()
s_output, S_err = countresult.communicate()
s_return = countresult.returncode
我正在寻找最少的代码和最少的库。谢谢
解决方案
推荐阅读
- javascript - 试图格式化一串名称的Javascript
- sql-server - SQL Server 中的多个连接问题 - 请提供建议
- c# - dotnet core 中的 httpwebrequest 返回 404 错误
- javascript - Promise inside loop get last Item 之后
- azure-functions - Azure 函数 - 防止多次调用
- php - 来自应用程序外部文件夹的 Codeigniter HMVC 错误 Ajax
- algorithm - 是否存在不需要后向边缘的增广路径序列?
- c++ - 如何在 Mac 上调试从 Java 调用的动态库中的代码
- sql - SQL - 复杂的 SQL 查询
- vue.js - 如何将 Bootstrap-Vue 输入的旧值传递给它调用的方法?