From: | Ed Behn <ed(at)behn(dot)us> |
---|---|
To: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: where and how to store calculated data? |
Date: | 2017-07-05 12:18:45 |
Message-ID: | 5ab060a8-1ed7-c43b-4427-d695ab17ddff@behn.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
I'm not sure exactly what you are asking but I have two thoughts.
* If you want a value to update automatically, the cleanest way to do
it it probably to to use a trigger that runs on UPDATE
(https://www.postgresql.org/docs/9.6/static/sql-createtrigger.html)
* If you are writing your client in python, psql is very much to
wrong way to interface with the database. You should be using psycopg2
(http://initd.org/psycopg/docs/)
-Ed
On 7/5/2017 7:20 AM, Rounak Jain wrote:
> I am creating a python CLI app with psql for invoicing.
>
> For sale_invoice_detail table, I have created columns,
> rate_after_discount and amount_after_discount. I do the appropriate
> calculations in my python code to set/update values in these columns
> when rate, qty, discount etc are set/modified.
>
> Now, I shall need the sum of the sub-totals (amount_after_discount of
> the above table). Should I save this amount in the sale_invoice table
> and ensure that the value gets updated when there is any related
> change in the sale_invoice_detail table or is there a better way?
From | Date | Subject | |
---|---|---|---|
Next Message | Stephen Froehlich | 2017-07-11 16:45:54 | COPY from temp table to main table insted of INSERT INTO |
Previous Message | Rounak Jain | 2017-07-05 11:20:40 | where and how to store calculated data? |