Issue
There is a program in flask and postgresql. Some of the data from the number is converted into money. On Windows, the thousands separator is
, this is visible in the browser console, but when you run the application on a Linux system, the separator turns into a space
. How can I make sure that on Linux the non-breaking space is also
? I don't use to_char
P.S. For Windows the number is shown as 20,000, for Linux as 2,000,000
The database query looks like this:
COALESCE(t1.account_money, 0)::money AS account_money
In html using jinja in one of the options the data looks like this:
<td class="th_main_sum_i">{{ application.account_money }}</td>
These are the locale settings in postgres on linux
Solution
PostgreSQL converts the data type money
to a string using the operating system's C library and the current setting of lc_monetary
. If the two operating systems have different ideas how money should be represented, that's not PostgreSQL's problem.
The PostgreSQL Wiki recommends that you don't use money
:
The money data type isn't actually very good for storing monetary values. Numeric, or (rarely) integer may be better.
With numeric
, you can use to_char
to format the output as you want.
Answered By - Laurenz Albe
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.