导入大型sql文件django [英] Import large sql file django

查看:210
本文介绍了导入大型sql文件django的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个sql文件,有~42,000 INSERT 语句

I have a sql file that has ~ 42,000 INSERT statements

我想知道什么是最好的,最快的将其导入现有表的方法?

I wondered what the best, and quickest way to import this into an existing table?

我使用的是django,刚刚安装了 South

I am using django and have just installed South too

欢迎任何建议。

我原本以为 - 绕过 models.py 并直接连接Sequel Pro for mac,但有些东西告诉我这不会让南方或django高兴。

I originally thought - just bypass models.py and directly connect through Sequel Pro for mac, but something tells me this won't make south or django happy.

推荐答案

通常这是使用事务完成的。编辑具有所有INSERT的文件。在顶部和底部添加一行:

Generally this is done using a transaction. Edit the file having all the INSERTs. Add a line on top and bottom:

BEGIN TRANSACTION;
-- all insert statements go here
COMMIT;

现在,一旦从命令行登录MySQL,执行

Now once you login to MySQL from the command line execute

mysql> source file_name

参见此处了解详情。

这篇关于导入大型sql文件django的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆