【发布时间】:2021-01-08 08:59:56
【问题描述】:
我正在尝试自动将数据记录到托管的 oh heroku 帐户的 postgres 数据库中。
import pexpect
import os
import sys
from time import sleep
#os.system("heroku login -i")
child = pexpect.spawn ('heroku login -i')
child.expect ('Email .*:')
child.sendline ('har**********@gmail.com')
child.expect ('Password:')
child.sendline ('js4*********SZq')
child.close(force=True)
#child.send('\r')
sleep(0.5)
child2 = pexpect.spawn ('heroku pg:psql postgresql-globular-95641 --app overal-vehicle')
child2.expect ('overal-vehicle::DATABASE=>')
child2.send ('SELECT version();')
child2.send('\r')
#在这部分之后我还想添加一些sql查询,但我无法登录,它只是告诉无效凭据,并通过浏览器登录。
这就是我想要达到的目标terminal screenshot
当我手动尝试时,所有命令都可以工作, 我想知道可能是什么问题,或者heroku通过某种方式检测到这是一项自动化任务,并且登录失败
请有人告诉我是什么问题,
【问题讨论】:
标签: python heroku-postgres pexpect os.system