Answer the question
In order to leave comments, you need to log in
Numpy and database queries?
Getting familiar with the numpy library. I tried to make a simple script for collecting data from the database. For some reason it gives an error:
TypeError: 'numpy.int32' object does not support indexing
import psycopg2
import numpy as np
selectDealersSQL = "SELECT dealer_id, name FROM public.dealers"
selectCountPointsSQL = 'SELECT count(*) FROM dealer_points WHERE point_type IN (1,2) AND active = TRUE AND dealer_id = %s'
conn = psycopg2.connect("dbname='***' user='nmurad' host='***.***.***.***' password='***'")
cur = conn.cursor()
cur.execute(selectDealersSQL)
rows = cur.fetchall()
points = np.array([], dtype='int8')
for row in rows:
points = np.append(points, row[0])
for point in points:
cur.execute(selectCountPointsSQL, point)
TypeError Traceback (most recent call last)
in ()
16
17 for point in points:
---> 18 cur.execute(selectCountPointsSQL, point)
TypeError: 'numpy.int32' object does not support indexing
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question