[Numpy-discussion] query to array

BBands bbands at gmail.com
Wed Jan 31 17:44:18 EST 2007

Good afternoon,

The following works:

import pyodbc
import numpy as np

connection = pyodbc.connect('DSN=DSNname')
cursor = connection.cursor()
symbol = 'ibm'
request = "select to_days(Date), Close from price where symbol = '" +
symbol + "' and date > '2006-01-01'"
for row in cursor.execute(request):
    price.append([row[0], row[1]])
    priceArray = np.array(price)

Is there a better way to do this? Can fromiter be used?

Could this query result be put into a wider array from the start such
that columns 2... could be filled with calcs later?

Thanks in advance,

John Bollinger, CFA, CMT

If you advance far enough, you arrive at the beginning.

More information about the NumPy-Discussion mailing list