我是python的新手,试图通过编写连接到我们的mysql数据库并做一些事情的服务器脚本来学习一些知识。我有python 3.3.1和mysql 5.0.96(社区)。我安装了mysql连接器/ python,并尝试使用mysql开发人员站点上的示例代码进行基本连接。这是我简单的python脚本:
#!/usr/local/bin/python3
import sys
import mysql.connector
db_config = {
'user': 'joebloggs',
'password': 'cleartext_passwd',
'host': '127.0.0.1',
'database': 'mydb'
}
cnx = mysql.connector.connect(**db_config)
cursor = cnx.cursor()
query = ('select usable_name, user_id from user')
cursor.execute(query)
for (usable_name, user_id) in cursor:
print("{} is the usable name of {d}".format(usable_name, user_id))
cursor.close()
cnx.close()
Run Code Online (Sandbox Code Playgroud)
但我在连接数据库时遇到错误
"Authentication with old (insecure) passwords "\
mysql.connector.errors.NotSupportedError: Authentication with old (insecure) passwords is not supported. For more information, lookup Password Hashing in the latest MySQL manual
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?任何帮助表示赞赏
我正在编写一些 bash 脚本来帮助自动化 AWS 资源的管理。我正在使用aws-cliand jq,到目前为止一切都很好。
我正在使用自定义标签标记我的资源。在某些情况下,我想根据Key和Value自定义标签过滤资源列表。但是我在制定一个简洁的jq查询来做到这一点时遇到了麻烦。
因此,例如,如果我的 ec2 实例的(修剪后的)JSON 输出类似于:
[
{
"PublicIpAddress": "11.22.33.44",
"PrivateIpAddress": "55.66.77.88",
"Tags": [
{
"Value": "live199.blah.com",
"Key": "Name"
},
{
"Value": "live-standalone",
"Key": "hc-class"
}
]
}
]
[
{
"PublicIpAddress": "111.222.333.444",
"PrivateIpAddress": "555.666.777.888",
"Tags": [
{
"Value": "staging99.blah.com",
"Key": "Name"
},
{
"Value": "staging-standalone",
"Key": "hc-class"
}
]
}
]
Run Code Online (Sandbox Code Playgroud)
...我需要在 whereTags.Key == "hc-class"和 中找到条目,Tags.Value = "staging-standalone"我该如何以简洁的方式做到这一点jq?
非常感谢任何帮助。