我需要通过python代码在Sql查询下运行并获取它的输出。 如何使用" os"模块。我无法在必须在python中执行此查询的系统上安装sql模块。
程序应运行此sql查询,检查数据库中的帐户ID并执行sql查询的输出。我很久没有使用过sql了解问题。
应该是这样的,但这里有些不对劲。
import os
id = raw_input("Enter account_id:")
os.system('sql2 -q abc.dev.domain.com "select account_name, account_id, is_enrolled from (select * from my_db where account_id = '$id' and is_enrolled = check by account_name')