小编Ser*_*nky的帖子

使用身份的 Fabrics 2.x ssh 连接无法工作

尝试使用 Fabrics 2 和身份文件连接到 ssh 配置中描述的主机。

con = Connection('my_host')
@task
def tt(c):
    con.run('uname -a')
Run Code Online (Sandbox Code Playgroud)

〜/ .ssh /配置:

Host my_host
    HostName 123.144.76.84
    User ubuntu
    IdentityFile ~/.keys/somekey
Run Code Online (Sandbox Code Playgroud)

它失败了

paramiko.ssh_exception.AuthenticationException:身份验证失败。

$ ssh my_host从终端工作。

我尝试过得到fab -i ~/.keys/somekey tt相同的结果。

python ssh fabric python-fabric-2

5
推荐指数
1
解决办法
2028
查看次数

Django 计算子查询中的行数

我需要计算子查询中的行数,这是我的 sqlite 解决方案。

class SQCount(Subquery):
    """Count lines in subquery"""
    template = "(SELECT count(*) FROM (%(subquery)s) _count)"
    output_field = models.IntegerField() 

sub = MyModel.objects.filter(user=OuterRef(OuterRef('id'))).values('id')
qs = qs.annotate(count_total=SQCount(sub))
Run Code Online (Sandbox Code Playgroud)

它适用于 sqlite,但不适用于 MySQL(抱怨“where”子句中的未知列)。任何帮助表示赞赏。

mysql django django-orm

3
推荐指数
1
解决办法
4038
查看次数

标签 统计

django ×1

django-orm ×1

fabric ×1

mysql ×1

python ×1

python-fabric-2 ×1

ssh ×1