4

I use PostgreSQL 9.1 and Django 1.6.2.

CREATE DATABASE db WITH ENCODING = 'UTF8' TEMPLATE template0;
CREATE USER db_user WITH password 'password';
GRANT ALL privileges ON DATABASE db TO db_user;

Then I want to load fixture:

python manage.py loaddata cars
Killed

What does it mean? Killed? All works perfect with mysql. Cars.yaml - its a very big file (it has russian words, do I need to create db with LC_COLLATE = 'ru_RU.UTF-8'?).

In mysql I use:

CREATE DATABASE `db` CHARACTER SET utf8 COLLATE utf8_general_ci;

And everything works fine. Please, help, I am newbie in PostgreSQL.

How to fix that problem with killed?

Leon
  • 6,316
  • 19
  • 62
  • 97

2 Answers2

5

Killed is a message displayed by the Unix shell, not by the python program itself.

This tells that the program finished with an error code indicating it has been killed with a SIGKILL signal (known as kill -9).

This may be the deed of the Linux OOM killer, if the python program (or another concurrent program) allocates large amounts of memory (see Return code when OOM killer kills a process).

Check out your kernel log for evidence of this (/var/log/kernel.log or similar). If this is indeed a problem of overcommitting memory, adding swap space to your system is likely to solve it.

Or if possible, improve the script to use less memory.

There's no obvious connection to how the database was created and its locale.

Community
  • 1
  • 1
Daniel Vérité
  • 58,074
  • 15
  • 129
  • 156
0

Use pg_restore() in terminal instead.

For big files django loaddata gets killed by the OS. One of the workaround is to dump your db data to archive and the load it directly to postgresql database. So if your dump is called dump.gz then you can load it to database using the following commands in your terminal:

gunzip dump.gz
pg_restore -d your_db -U user_name --no-owner dump
Max Drobin
  • 1
  • 1
  • 1