目前,我使用EncryptedTypefromsqlalchemy_utils来自动加密进入表的数据,并在从表中检索数据时解密数据,使用一些预定义的字符串作为加密密钥。这工作正常,但现在需求发生了变化,虽然我仍然需要在进入表的路上加密数据,但我现在需要在检索数据时保持加密。我不确定这是否EncryptedType支持,或者是否有任何其他方法可以使用 SQLAlchemy 来做到这一点,而无需在我假设的密码库中使用我自己的方法。
我的表的例子:
class MyTable(db.Model):
__tablename__ = "my_table"
id = db.Column(db.Integer, primary_key=True, autoincrement="auto")
name = db.Column(db.String(50), nullable=False)
username = db.Column(EncryptedType(db.String, _key), nullable=True)
password = db.Column(EncryptedType(db.String, _key), nullable=True)
Run Code Online (Sandbox Code Playgroud) 我正在尝试在PyPI上提供一个软件包。我已将其上传到PyPI,可以按以下方式安装:
pip install autostager。但是,打开外壳并尝试导入它无法按预期方式工作:
>>> import autostager
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named autostager
Run Code Online (Sandbox Code Playgroud)
供参考,这里是 setup.py
from distutils.core import setup
setup(
name = 'autostager',
packages = ['autostager'],
version = '0.1',
description = 'Stage a directory based on Github pull request (e.g., dynamic puppet environments)',
author = 'Jordan Facibene',
author_email = 'jordan.facibene13@stjohns.edu',
url = 'https://github.com/jfach/autostager',
download_url = 'https://github.com/jfach/autostager/tarball/0.1',
keywords = ['github', 'automation', 'staging'],
classifiers = []
)
Run Code Online (Sandbox Code Playgroud)
作为参考,可以在以下位置找到我的存储库:https : //github.com/jfach/autostager …
当我遇到以下情况时,我正在解决问题的解决方案......
我开始创建一个变量test,并将其初始化为一个列表.
test = [3, 2, 1]
Run Code Online (Sandbox Code Playgroud)
在.sort()我的名单上玩并调用它后test,我尝试使用print如下:
print test.sort(reverse = True)
Run Code Online (Sandbox Code Playgroud)
输出是None,我只是好奇为什么这是.