'How to query an array of FLOAT?
I have a table with a column with type double precision[]
created like this:
from sqlalchemy import Column, String, ARRAY
mytablename= 'mytable'
class create_my_array_table(Base):
__tablename__ = mytablename
id = Column(String(3000, convert_unicode= False), primary_key= True)
myarray= Column(ARRAY(Float), unique=False)
So if I have an array (Python list) v, this is how I'm trying to query it.
v = [0.0112, 0.235, 0.25...]
myDBtable= Table(mytablename, metadata, autoload = True, autoload_with = engine)
myquery =session.query(myDBtable).filter(myDBtable.c.vector ==v)
##test
for line in myquery:
print(line)
I'm getting this error:
psycopg2.ProgrammingError: operator does not exist: double precision[] = numeric[]
LINE 3: WHERE mytable.myarray= ARRAY[0.0112, 0.235...
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|