我想从mysql数据库中检索数据,但是我需要做的是使数据的公共值作为所有检索到的数据的标题
表格示例:
ID |姓名| orderDate |
1 ||约翰| 10-07-2019 |
2 ||毁灭10-07-2019 |
3 || Allyc的| 10-07-2019 |
4 ||戴安娜| 2019年11月11日|
5 ||赛伦| 2019年11月11日|
6 ||杰基| 12-07-2019 |
所以我希望我的结果像这样
2019年10月7日
1.约翰
2. Maige
3. Allyc
11-07-2019
4.黛安娜
5.瑟伦
2019年12月7日
6. Jacky
预先感谢...
答案 0 :(得分:0)
您应该在前端而不是db-in OO编程术语中执行此操作,而是将行视为对象的实例。创建纯粹不同类型的伪造对象并将它们插入到列表中纯粹是出于演示目的,这是一个丑陋的hack ..
import h5py
import numpy as np
import os
import sys
import doctest
def write_dh5_np(h5_name, np_array):
"""
:param h5_name: Name of a h5 file
:type h5_name: str
:param np_array: Array of floats
:type np_array: np.array
"""
assert not os.path.isfile(h5_name), "Won't overwrite {}".format(h5_name)
with h5py.File(h5_name, 'w') as h5_file:
h5_file.create_dataset('np_array', data=np_array)
def read_hd5_np(h5_name):
"""
:param h5_name: Name of a h5 file
:type h5_name: str
:returns: Data in h5 file
:rtype: np.array
"""
with h5py.File(h5_name, 'r') as h5_file:
np_array = h5_file['np_array'][()]
return np_array
def convert_to_txt(h5_name, txt_name=None):
"""
:param h5_name: Name of a h5 file
:type h5_name: str
:param txt_name: Name of a txt file to be created
:type txt_name: str
:returns: Name of a txt file that was created
:rtype: str
"""
if txt_name is None:
strip_name = os.path.splitext(h5_name)[0]
txt_name = '{}.txt'.format(strip_name)
assert not os.path.isfile(txt_name), "Won't overwrite {}".format(txt_name)
np_array = read_hd5_np(h5_name)
np.savetxt(txt_name, np_array)
return txt_name
if __name__ == "__main__":
args = sys.argv[1:]
if not args:
doctest.testmod()
else:
hdf5_name = sys.argv[1]
try:
txt_name = sys.argv[2]
except IndexError:
txt_name = None
convert_to_txt(hdf5_name, txt_name)
U。因此,我们生成了一些带有s格式化日期,日期(作为日期)和0(小于id)的假行,并将它们与实际数据日期,id和s格式化的文本结合在一起。当按日期对大量数据(假数据和真实数据)进行排序时,然后依次排列构成“标题”的伪行,然后显示数据,然后显示下一个标题
请在前端执行