本文整理汇总了Python中vilya.libs.store.store.execute函数的典型用法代码示例。如果您正苦于以下问题:Python execute函数的具体用法?Python execute怎么用?Python execute使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了execute函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_product
def update_product(self, product):
store.execute("update codedouban_projects "
"set product=%s "
"where project_id=%s",
(product, self.id))
store.commit()
self.clear_mc(self.id)
示例2: add
def add(
cls,
title,
description,
creator,
number=None,
team=None,
project=None,
assignee=None,
closer=None,
created_at=None,
updated_at=None,
closed_at=None,
):
issue = Issue.add(
title, description, creator, assignee=assignee, closer=closer, type=cls.target_type, target_id=project
)
if issue and project:
number = PICounter.incr(project, number)
store.execute(
"insert into project_issues (project_id, issue_id, number) " "values (%s, %s, %s) ",
(project, issue.id, number),
)
store.commit()
mc.delete(MC_KEY_PROJECT_ISSUE_CREATOR_N % (project, creator, "open"))
mc.delete(MC_KEY_PROJECT_ISSUE_CREATOR_N % (project, creator, "closed"))
cls._clean_cache(project)
return Issue.get_cached_issue(issue.id)
示例3: add
def add(cls, description, owner_id, is_public, gist_names=[],
gist_contents=[], fork_from=None):
now = datetime.now()
if fork_from:
name = cls.get(fork_from).name
id = store.execute(
"insert into gists "
"(`name`, `description`, `owner_id`, `created_at`, `fork_from`) " # noqa
"values (%s, %s, %s, %s, %s)",
(name, description, owner_id, now, fork_from))
store.commit()
gist = cls.get(id)
fork_from = cls.get(fork_from)
fork_from.fork_repo(gist)
gist_forked_signal.send(gist, gist_id=gist.id)
else:
name = cls._get_name(names=gist_names)
id = store.execute(
"insert into gists "
"(`name`, `description`, `owner_id`, `is_public`, `created_at`) " # noqa
"values (%s, %s, %s, %s, %s)",
(name, description, owner_id, is_public, now))
store.commit()
gist = cls.get(id)
gist.create_repo()
gist._commit_all_files(gist_names, gist_contents, create=True)
gist_created_signal.send(gist, gist_id=gist.id)
return gist
示例4: discover
def discover(cls, name, sort='created', direction='desc', start=0,
limit=5):
assert sort in SORTS
assert direction in DIRECTIONS
sortby = "order by %s_at %s " % (sort, direction)
sort = '%s_at' % sort
reverse = direction == 'desc'
if name == 'forked':
rs = store.execute("select distinct(fork_from) from gists "
"where fork_from!=0 and is_public=1 " +
sortby + "limit %s, %s",
(start, limit))
return [cls.get(r) for r, in rs]
elif name == 'starred':
rs = store.execute("select distinct(gist_id) from gist_stars "
"order by created_at " +
direction + " limit %s, %s",
(start, limit))
gists = filter(None, [cls.get(r) for r, in rs])
return sorted(gists, key=lambda g: getattr(g, sort),
reverse=reverse)
else:
rs = store.execute(
"select id, name, description, owner_id, is_public, "
"fork_from, created_at, updated_at from gists where "
"is_public=1 " + sortby + "limit %s, %s",
(start, limit))
return [cls(*r) for r in rs]
示例5: update_summary
def update_summary(self, summary):
store.execute("update codedouban_projects "
"set summary=%s "
"where project_id=%s",
(summary, self.id))
store.commit()
self.clear_mc(self.id)
示例6: test_project_stat
def test_project_stat(self):
store.execute("delete from codedouban_projects where project_id < 5")
project_rs = get_all_project()
assert len(project_rs) == 0
project_fork_count = len(filter(lambda x: x[1] is not None,
project_rs))
assert project_fork_count == 0
project_name = "project"
project = CodeDoubanProject.add(
project_name, owner_id="test1", summary="test", product="fire")
git_path = os.path.join(get_repo_root(), '%s.git' % project_name)
ok_(os.path.exists(git_path))
project_rs = get_all_project()
assert len(project_rs) == 1
project_fork_count = len(filter(lambda x: x[1] is not None,
project_rs))
assert project_fork_count == 0
project_fork = project.fork('project_test_fork', 'test_fork')
project_rs = get_all_project()
assert len(project_rs) == 2
project_fork_count = len(filter(lambda x: x[1] is not None,
project_rs))
assert project_fork_count == 1
project.delete()
project_fork.delete()
示例7: add
def add(cls, name, followed_user_name):
time = datetime.now()
store.execute('insert into follow_relationship '
'(user_name, followed_user_name, time) '
'values (%s, %s, %s)',
(name, followed_user_name, time))
store.commit()
示例8: main
def main():
rs = store.execute("select id "
"from codedouban_ticket")
for r in rs:
id, = r
ticket = Ticket.get(id)
# update merge
pullreq = PullRequest.get_by_ticket(ticket)
author = pullreq.merge_by or pullreq.to_proj.owner_id
time = pullreq.merge_time
ticket_id = ticket.id
id = 0
if not get_node(author, TICKET_NODE_TYPE_MERGE, id, ticket_id, time) and time:
print id, author, time, ticket_id
store.execute("insert into ticket_nodes "
"(author, type, type_id, ticket_id, created_at) "
"value (%s, %s, %s, %s, %s)",
(author, TICKET_NODE_TYPE_MERGE, id, ticket_id, time))
store.commit()
# update close
author = ticket.close_by or ticket.author
time = ticket.closed
ticket_id = ticket.id
id = 0
if not get_node(author, TICKET_NODE_TYPE_CLOSE, id, ticket_id, time) and time:
print id, author, time, ticket_id
store.execute("insert into ticket_nodes "
"(author, type, type_id, ticket_id, created_at) "
"value (%s, %s, %s, %s, %s)",
(author, TICKET_NODE_TYPE_CLOSE, id, ticket_id, time))
store.commit()
print "update %s close & merge pulls" % len(rs)
示例9: update_intern_banned
def update_intern_banned(self, banned):
store.execute("update codedouban_projects "
"set intern_banned=%s "
"where project_id=%s",
(banned, self.id))
store.commit()
self.clear_mc(self.id)
示例10: add_committer
def add_committer(cls, proj_id, user_id):
try:
store.execute("insert into codedouban_committers "
"(project_id, user_id) values (%s, %s)",
(proj_id, user_id))
except IntegrityError:
return None
store.commit()
示例11: update
def update(self, title, description):
store.execute("update issues "
"set title=%s, updated_at=null "
"where id=%s", (title, self.issue_id))
store.commit()
bdb.set(BDB_ISSUE_DESCRIPTION_KEY % self.issue_id, description)
self.clear_cache()
mc.delete(MC_KEY_ISSUES_DATA_BY_TARGET % (self.type, self.target_id))
示例12: delete
def delete(self):
store.execute('delete from issues where id=%s', (self.id,))
store.commit()
mc.delete(MC_KEY_ISSUE % self.id)
mc.delete(MC_KEY_ISSUES_IDS_BY_CREATOR_ID % self.creator_id)
mc.delete(MC_KEY_ISSUES_IDS_BY_ASSIGNEE_ID % self.assignee_id)
mc.delete(MC_KEY_ISSUES_DATA_BY_TARGET % (type, self.target_id))
bdb.set(BDB_ISSUE_DESCRIPTION_KEY % self.id, '')
示例13: get_item_count
def get_item_count(name):
if name == '':
rs = store.execute("select count(1) from badge_item")
else:
rs = store.execute(
"select count(1) from badge_item where item_id=%s", (name,))
data = rs and rs[0]
return data
示例14: update_can_push
def update_can_push(self, can_push):
push = 1 if can_push else 0
store.execute("update codedouban_projects "
"set can_push=%s "
"where project_id=%s",
(push, self.id))
store.commit()
self.clear_mc(self.id)
示例15: assign
def assign(self, user_id):
old_id = self.assignee_id
store.execute("update issues "
"set assignee_id=%s "
"where id=%s", (user_id, self.issue_id))
store.commit()
self.clear_cache()
mc.delete(MC_KEY_ISSUES_IDS_BY_ASSIGNEE_ID % old_id)
mc.delete(MC_KEY_ISSUES_IDS_BY_ASSIGNEE_ID % user_id)