File tree Expand file tree Collapse file tree 1 file changed +9
-12
lines changed
students/visokoo/lesson03/assignment/src Expand file tree Collapse file tree 1 file changed +9
-12
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,6 @@ def add_customer(customer_id,
45
45
email_address = email_address ,
46
46
status = status ,
47
47
credit_limit = credit_limit )
48
- new_customer .save ()
49
48
LOGGER .info ("DATABASE add successful" )
50
49
except peewee .IntegrityError :
51
50
LOGGER .info ("Unique constraint failed on %s" , customer_id )
@@ -65,12 +64,11 @@ def search_customer(customer_id):
65
64
"""
66
65
query_dict = {}
67
66
try :
68
- with DATABASE .transaction ():
69
- query = (
70
- Customer
71
- .select ()
72
- .where (Customer .customer_id == customer_id ).get ())
73
- query_dict = model_to_dict (query )
67
+ query = (
68
+ Customer
69
+ .select ()
70
+ .where (Customer .customer_id == customer_id ).get ())
71
+ query_dict = model_to_dict (query )
74
72
except peewee .DoesNotExist :
75
73
LOGGER .info ("Can't find customer with id: %s." , customer_id )
76
74
LOGGER .info ("Returning empty dict." )
@@ -117,11 +115,10 @@ def list_active_customers():
117
115
:rtype int
118
116
"""
119
117
try :
120
- with DATABASE .transaction ():
121
- active_customers = (
122
- Customer
123
- .select ()
124
- .where (Customer .status == "active" ).count ())
118
+ active_customers = (
119
+ Customer
120
+ .select ()
121
+ .where (Customer .status == "active" ).count ())
125
122
except peewee .DoesNotExist :
126
123
LOGGER .info ("No active customers found in DB" )
127
124
return active_customers
You can’t perform that action at this time.
0 commit comments