将关系数据库转换为平面数据库,反之亦然
我想编写一个脚本来从关系数据库转换为平面数据库,反之亦然。数据库的行主要包含来自文本输入的数据,但表单中有一些下拉列表,用于输入另一个表中的行的主 ID。目前,我的数据库行看起来像:
(1, 4, 2, 45.508582, -73.610102, 3),我想将其转换为:
(1, Sherbrooke, "Park Frontenac", 45.508582, -73.610102, John, Doe)回到上面。
有些表的每个主 ID 包含一列(例如城市和公园表),但其他表则包含 2 列或更多列(例如人员表)。
为此编写脚本的最简单方法是什么?尽管我计划很快开始学习 python,但我对基本 php 之外的脚本编写感到不舒服。
I'd like to write a script to convert from a relational database to a flat one and vice-versa. The database's rows mostly contain data from text input, but there are a few dropdown lists from the form that enter the primary IDs of a row from another table. Currently I have database rows that would look like say:
(1, 4, 2, 45.508582, -73.610102, 3) that I want turned into:
(1, Sherbrooke, "Park Frontenac", 45.508582, -73.610102, John, Doe) and this back to the above.
Some tables contain one column per primary ID (like city and park tables), but others have 2 or more (like the persons table).
What's the easiest way to write a script for this? I'm not comfortable with scripting outside of basic php, although I plan to start learning python soon.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
进行 SQL 查询以提供所需的数据
,并使用 sqlalchemy 将创建并运行脚本,
每一行将包含包含所需数据的元组
Make SQL-query for that gives needed data
and using sqlalchemy will create and run your script
each row would be have tuple with needed data