inspectdb changes encoding from UTF-8 to UTF 16-le

hi all,

here a relative new Django user. When I’m trying to import a PostgreSQL table with inspectdb I get the issue that my encoding changes from UTF-8 to UTF 16-le, what I’m doing wrong? My PostgreSQL database is in UTF-8 and my original models.py to (until I execute the inspectdb).

here my database table:
CREATE TABLE public.rainbucket (
berichtid varchar(40) NOT NULL,
device_id text NULL,
ontvangsttijd timestamp(6) NULL DEFAULT now(),
batterij_voltage float8 NULL,
cumulative_precipitation float8 NULL,
precipitation float8 NULL,
precipitation_interval float8 NULL,
isodow int4 NULL DEFAULT date_part(‘isodow’::text, now()),
“time” time NULL DEFAULT now()
);

and my class after I execute “python manage.py inspectdb rainbucket > myapi\models.py”

does anyone know a solution because I couldn’t find documentation about it?

1 Like

I’d try directing that output to a different file, and using an editor to see what sort of odd characters may have been inserted.

(What I’m really guessing is happening is that there’s some line-termination character mismatch involved. Personally I doubt that it’s actually changing the encoding of the file.)

Hmmm strange. I restarted my complete project and tried it again but with the same result. When I open the models.py with notepad it changed from utf-8 to utf 16-le after the inspectdb command. If I change it back with notepad, all works fine, until the next inspectdb command