如何使用SQLAlchemy/Mysql存储3D图形(x,y,z)数据?
我正在使用Python的Flask将3D图形的X,Y,Z值赋给Javascript(Plotly库)。数据是这样的:如何使用SQLAlchemy/Mysql存储3D图形(x,y,z)数据?
z = [1,1,1,1,1,1,1,1,1,1,1,1]; x = [0.0100,0.0420,0.0500,0.0508,0.0769,0.0883,0.0900,0.1101,0.1256,0.1300,0.1385,0.1607];
y = [0.0131,0.0190,0.0248,0.0250,0.0310,0.0370,0.0384,0.0430,0.0490,0.0530,0.0550,0.0610];
所有这些都为1个的3D图形和它看起来像这样:
问题是,我会在我的网站很多3D图形和他们都储存在代码中的Python数组很荒谬。将所有这些坐标存储在数据库中最有效的方法是什么?谢谢。
回答:
您可以使用PostgreSQL数据库,这是有数组的,所以,你可以创建一个表,你会包含列:
id: integer graph_name: text
xpoints: double precision[]
ypoints: double precision[]
zpoints: double precision[]
其中,“双精度[]”是8个字节的float数组数据类型。
所以每个图都会存储在表的一行中。
对于数组列,你应该使用postgresql.ARRAY数据类型(在SQLAlchemy中)
以上是 如何使用SQLAlchemy/Mysql存储3D图形(x,y,z)数据? 的全部内容, 来源链接: utcz.com/qa/264603.html