python - 从输入/文件自动创建 MySQL 表

标签 python mysql database database-design

Possible Duplicate:
Generate table schema inspecting Excel(CSV) and import data

我正在开发一个根据输入自动创建 MySQL 表的工具。

例如。

输入

Y|abc|123|1.12|2012-12-20 00:00:00

输出

CREATE TABLE MyTable (
 is_enabed char(1),
 call_sign varchar(8),
 facility_id tinyint(4),
 bounds decimal(4,2)
 created_time datetime
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1

我现在有一个用 Python 编写的准工作原型(prototype)。在深入研究之前,我想看看是否已经存在类似的项目(免费、开源)。如果是这样,我的努力可能会更好地花在研究该项目上,而不是不知疲倦地重新发明轮子。

最佳答案

Generate table schema inspecting Excel(CSV) and import data

这个问题(以及最上面的回复,提到xlrd)已经讨论了这个主题。

事实上,MySQL 显然内置了这样的函数:

https://dev.mysql.com/doc/refman/5.0/en/procedure-analyse.html

ANALYSE() examines the result from a query and returns an analysis of the results that suggests optimal data types for each column that may help reduce table sizes.

关于python - 从输入/文件自动创建 MySQL 表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12992796/

相关文章:

Android 备份/恢复 : how to backup an internal database?

database - 在 Informix 上查找长时间运行的查询?

mysql - 如何在codeigniter中编写CHAR_LENGTH sql查询

php - 选择并取消链接 3 个表上的文件

python - Pandas:将 csv 文件加载为列表

python - mysql.connector.errors.ProgrammingError : Not all parameters were used in the SQL statement

php - 如何使用 PHP MySQL 连接到新数据库

更新json的数据库函数

python - 如何在 Kivy TextInput 中使用 .svg 图形?

Python:将整数重新排列为最大回文数