简体   繁体   English

使用Python将DBF文件导入MySql数据库

[英]Importing DBF files into MySql Database using Python

Is there a python code or libraries where I can import DBF files into a MySql database?是否有可以将 DBF 文件导入 MySql 数据库的 Python 代码或库? because all i know is a csv file into mysql, but i would like to import directly the DBF into mysql where theres no need to convert the dbf into a csv.因为我所知道的只是一个 csv 文件到 mysql,但我想直接将 DBF 导入到 mysql 中,而无需将 dbf 转换为 csv。

Thanks in advance.提前致谢。

Is there a python code or libraries where I can import DBF files into a MySql database?是否有可以将 DBF 文件导入 MySql 数据库的 Python 代码或库?

No. MySql container files are not designed as an export/import format to be moved from machine to machine.MySql的容器文件不被设计成一个导出/导入格式从机器移动到机器。 What you propose does not work.你的建议行不通。 Seriously.严重地。 Ask me sometime how I know.有时间问我是怎么知道的。

If you need a self-contained file-based SQL setup, consider using sqlite instead of mysql.如果您需要一个独立的基于文件的 SQL 设置,请考虑使用sqlite而不是 mysql。

You can use mysqldump to write .sql files holding everything in a database, then load them into another server.您可以使用 mysqldump 编写包含数据库中所有内容的 .sql 文件,然后将它们加载到另一台服务器中。

The MySQL server software comes with the mysql , mysqldump , and mysqladmin command line programs as part of the package. MySQL 服务器软件附带mysqlmysqldumpmysqladmin命令行程序,作为软件包的一部分。 The way to move a database from one MySQL server to another is to dump the database to a .sql file, and then load that file into the other server.将数据库从一台 MySQL 服务器移动到另一台服务器的方法是将数据库转储到.sql文件,然后将该文件加载到另一台服务器中。 You'll only run into trouble with this if your database contains more than a few GiB of data.如果您的数据库包含超过几个 GiB 的数据,您只会遇到这个问题。

mysqldump generates .sql to create your tables and to put your data into them. mysqldump 生成 .sql 来创建您的表并将您的数据放入其中。 It's the best way to copy or move a database from one server to another.这是将数据库从一台服务器复制或移动到另一台服务器的最佳方式。

Let's say your source server is on your own localhost machine, and the destination is on myserver.example.com .假设您的源服务器在您自己的localhost上,而目的地在myserver.example.com And let's say your username on both MySQL machines is artu , and your database name is deetu .假设您在两台 MySQL 机器上的用户名是artu ,而您的数据库名称是deetu

Export the database like this:像这样导出数据库:

mysqldump -u artu -p deetu > deetudump.sql

Then on your target machine create the database and restore the .sql dump file.然后在您的目标机器上创建数据库并恢复 .sql 转储文件。

mysqladmin -h myserver.example.com -u artu -p create deetu
mysql -h myserver.example.com -u artu -p deetu < deetudump.sql

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM