我正在使用MySQLdb包与MySQL进行交互.我无法获得正确的类型转换.
我使用一个16字节的二进制uuid作为表的主键,并有一个mediumblob保存zlib压缩的json信息.
我正在使用以下架构:
CREATE TABLE repositories (
added_id int auto_increment not null,
id binary(16) not null,
data mediumblob not null,
create_date int not null,
update_date int not null,
PRIMARY KEY (added_id),
UNIQUE(id)
) DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ENGINE=InnoDB;
Run Code Online (Sandbox Code Playgroud)
然后我使用以下代码在表中创建一个新行:
data = zlib.compress(json.dumps({'hello':'how are you :D'})
row_id = uuid.uuid(4).hex
added_id = cursor.execute('
INSERT INTO repositories (id, data, create_date, update_date)
VALUES (%s, %s, %s, %s)',
binascii.a2b_hex(row_id),
data,
time.time(),
time.time()
)
Run Code Online (Sandbox Code Playgroud)
然后检索数据我使用类似的查询:
query = cursor.execute('SELECT added_id, id, data, create_date, update_date ' \
'FROM repositories …Run Code Online (Sandbox Code Playgroud) 我解析了一个具有以下结构的json对象:
{
data = "<null>";
"error_type" = "INPUT_ERROR";
msg = "Missing field parameter";
success = 0;
}
Run Code Online (Sandbox Code Playgroud)
我正在尝试做一个compariosn,看看成功是真还是假,但是它有效并给我一个警告,说你不能将指针作为整数进行比较.我也尝试过NO和YES.
任何帮助将不胜感激.
我无法通过导航提交树找到标记指向的提交.对于此特定示例,我使用直接从Github克隆的Tornado Web存储库.
import sys
import git
if len(sys.argv) < 2:
print 'python git_test.py <repo path>'
sys.exit(0)
repo = git.Repo(sys.argv[1])
commits = {}
for git_commit in repo.iter_commits():
commits[git_commit.hexsha] = git_commit
print len(commits)
for git_tag in repo.tags:
print 'Tag %s points to Commit %s' % (
git_tag.name,
commits[git_tag.commit.hexsha]
)
Run Code Online (Sandbox Code Playgroud)
这是假设在git的直接非循环图中找到所有提交,但是,我尝试了另一种方法,通过递归函数递归地导航dag并且它传递了相同的结果.
ian@ian-EP45-UD3L:~/code/playground$ python git_test.py ~/code/tornado/
459
Tag v1.0.0 points to Commit eb5b3d8df7a305ac1ffa0a12c813e5d7ee4d6cd3
Traceback (most recent call last):
File "git_test.py", line 19, in <module>
commits[git_tag.commit.hexsha]
KeyError: '2b5064b7ed962603ade0db0c8e21846a9879e30e'
Run Code Online (Sandbox Code Playgroud)
我做错了什么,我该如何解决这个问题?任何帮助表示赞赏!
我正在使用git-python v0.3.1.
我有一个NSDictionary,具有以下布局:
{
1:{
... some data ...
}
...
}
Run Code Online (Sandbox Code Playgroud)
我有一个整数值为1的NSNumber对象,但是当我这样做
[my_dict objectForKey:my_number]时返回null.
如果我尝试将NSNumber转换为整数,[my dict objectForKey:[my_number intValue]]我会收到警告,当程序到达代码的那一部分时程序会崩溃.
任何帮助将不胜感激.