[Numpy-discussion] query to array
kwgoodman at gmail.com
Wed Jan 31 18:00:12 EST 2007
On 1/31/07, BBands <bbands at gmail.com> wrote:
> 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, row])
> priceArray = np.array(price)
> Is there a better way to do this? Can fromiter be used?
Why not just pull it all at once with cursor.fetchall()? Then use
np.asarray on the result.
More information about the NumPy-Discussion