olmalıdır. numpy.recarray
[('a', '<i4'), ('b', '<i4'), ('c', '<i4')]
alternatif arkadaşınız,
from sqlite3 import connect
from numpy import asarray
db = connect(":memory:")
c = db.cursor()
c.execute('create table bigtop (a int, b int, c int)')
for v in [(1,2,3),(4,5,6),(7,8,9)]:
c.execute('insert into bigtop values (?,?,?)',v)
s = c.execute('select * from bigtop')
h = [(i[0],int) for i in c.description]
# You can also use 'object' for your type
# h = [(i[0],object) for i in c.description]
a = asarray(list(s),dtype=h)
print a['a']
ilk sütunu verir
print a.dtype
her sütunun adını ve türünü verir
[1 4 7]
ve, olduğu eğer kullandıysan türünüze olarak object
, size dizideki ilk satır olarak sütun adlarını istese,
top = csr.execute("Select * from bigtop")
d=list(top)
a = np.asarray([[x[0] for x in top.description]] + d, dtype='object')
yapacağını
[('a', '|O4'), ('b', '|O4'), ('c', '|O4')]
ama lafrasu'nun başlık adlarını, 'a.dtype.names' olarak erişebileceğiniz dtype adlarına koyma fikrini seviyorum. Ardından, kodları koddaki * veya * adlarına göre dizine ekleyebilirsiniz. –