-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset_bn_cost.py
More file actions
39 lines (34 loc) · 1.25 KB
/
Copy pathset_bn_cost.py
File metadata and controls
39 lines (34 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from database import Database, CursorFromConnectionFromPool as conn
from prompt_toolkit.styles import Style
from psycopg2 import sql
from reportlab.lib import pagesizes
from prettytable import PrettyTable
from fuzzyfinder import fuzzyfinder as ff
import common_functions as cf
import owner
import product
import sys
import os
import master
from decimal import Decimal
import required.custom_data as custom_data
name_ = 'Barrel Nipple'
size = str(100)
name_size = name_ + " " + size
name_like = name_size + " " + "%" # to avoid 150 while looking for 15, a space is must
Database.initialise(database='chip', host='localhost', user='dba_tovak')
with conn() as cursor:
cursor.execute("select cost from product where name = %s", (name_size,))
cost = cursor.fetchone()[0]
print(cost)
with conn() as cursor:
cursor.execute("select name, cost from product where name like %s", (name_like,))
result = cursor.fetchall()
for a in result:
product_name = a[0]
sub_size = product_name.split("x")[1]
# print(sub_size)
cost_sub_size = (Decimal(cost/12)*Decimal(sub_size)).quantize(Decimal("1.00"))
# print(cost_sub_size)
with conn() as cursor:
cursor.execute("update product set cost = %s where name = %s", (cost_sub_size, product_name))