Skip to content

Commit

Permalink
更新数据库操作逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
Ehco1996 committed Nov 8, 2017
1 parent 5af0982 commit 0184045
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion 豆瓣影评/锤神3/stroe.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ def save_one_data(self, table, data,):
except:
print('数据库保存错误')
return -1
finally:
self.close()

def find_all(self, table, limit):
'''
Expand All @@ -83,6 +85,8 @@ def find_all(self, table, limit):
except:
print('数据查询存错误')
return -1
finally:
self.close()

def find_by_field(self, table, field, field_value):
'''
Expand All @@ -105,6 +109,8 @@ def find_by_field(self, table, field, field_value):
except:
print('数据查询存错误')
return -1
finally:
self.close()

def find_by_fields(self, table, queryset={}):
'''
Expand All @@ -124,13 +130,15 @@ def find_by_fields(self, table, queryset={}):
querrys += "{} = '{}' and ".format(k, v)
sql = "select * from {} where {} ".format(
table, querrys[:-4])
print(sql)
cursor.execute(sql)
res = cursor.fetchall()
return res
except:
print('数据查询存错误')
return -1
finally:
self.close()


def find_by_sort(self, table, field, limit=1000, order='DESC'):
'''
Expand All @@ -154,3 +162,5 @@ def find_by_sort(self, table, field, limit=1000, order='DESC'):
except:
print('数据查询存错误')
return -1
finally:
self.close()

0 comments on commit 0184045

Please sign in to comment.