我使用PostgreSQL 9.1和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;
然后我想加载夹具:
python manage.py loaddata cars
Killed
这是什么意思? 终止?所有的工作都完美的mysql。 Cars.yaml - 它是一个非常大的文件(它有俄语单词,我是否需要使用LC_COLLATE ='ru_RU.UTF-8'创建数据库?)。
在mysql中我使用:
CREATE DATABASE `db` CHARACTER SET utf8 COLLATE utf8_general_ci;
一切正常。请帮忙,我是PostgreSQL的新手。
如何使用killed
解决该问题?
答案 0 :(得分:2)
Killed
是Unix shell显示的消息,而不是python
程序本身显示的消息。
这告诉程序完成了一个错误代码,表明它已被SIGKILL
信号(称为kill -9
)杀死。
如果python
程序(或其他并发程序)分配大量内存(参见OOM killer),这可能是Linux Return code when OOM killer kills a process的契约。
查看您的内核日志以获取此证据(/var/log/kernel.log
或类似内容)。
如果这确实是过度使用内存的问题,那么向系统添加交换空间可能会解决它。
或者,如果可能的话,改进脚本以减少内存使用。
与数据库的创建方式及其区域设置没有明显的联系。
答案 1 :(得分:0)
在终端中使用// You need to use babel present env for this
async componentDidMount() {
const refresh_token = localStorage.getItem('access_token');
let isTokenActive = false;
try {
const response = awit fetch('http://localhost:8888/refresh_token?refresh_token=' + refresh_token);
const data = await response.json();
// console.log(data);
isTokenActive = true;
} catch(err) {
// Log the error
}
}
// Conditional rendering
this.state = {
...,
isLoading: false,
isTokenActive: false
};
componentDidMount() {
const refresh_token = localStorage.getItem('access_token');
this.setState({ isLoading: true });
fetch('http://localhost:8888/refresh_token?refresh_token=' + refresh_token)
.then(...)
.catch(...)
.finally(...); // Set the value for isLoading/isTokenActive with this.setState accordingly
}
render() {
const { isLoading, isTokenActive } = this.state;
!isLoading ? isTokenActive ? <MyComponent /> : <div /> : <div>Loading...</div>;
}
。
对于大文件,django loaddata被操作系统杀死。解决方法之一是转储您的db数据以存档,并将其直接加载到postgresql数据库。因此,如果您的转储名为dump.gz,则可以在终端中使用以下命令将其加载到数据库中:
pg_restore()