Skip to content

Commit 786c578

Browse files
committed
Merge branch 'master' of github.com:visokoo/Python220A_2019
2 parents f8aee66 + cfc7163 commit 786c578

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

students/visokoo/lesson03/assignment/src/basic_operations.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ def add_customer(customer_id,
4545
email_address=email_address,
4646
status=status,
4747
credit_limit=credit_limit)
48-
new_customer.save()
4948
LOGGER.info("DATABASE add successful")
5049
except peewee.IntegrityError:
5150
LOGGER.info("Unique constraint failed on %s", customer_id)
@@ -65,12 +64,11 @@ def search_customer(customer_id):
6564
"""
6665
query_dict = {}
6766
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)
7472
except peewee.DoesNotExist:
7573
LOGGER.info("Can't find customer with id: %s.", customer_id)
7674
LOGGER.info("Returning empty dict.")
@@ -117,11 +115,10 @@ def list_active_customers():
117115
:rtype int
118116
"""
119117
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())
125122
except peewee.DoesNotExist:
126123
LOGGER.info("No active customers found in DB")
127124
return active_customers

0 commit comments

Comments
 (0)