Hello, I'm trying to figure out a streamlined way to store some children
values that are stored in numpy arrays in Python. As example let's assume I
have a parent object that is a sensor that has some readings associated to
it:
class Sensor(object):
__tablename__ = 'sensor'
id = Column(Integer, primary_key=True),
name = Column(String)
readings = relationship("Reading", backref="sensor")
class Reading(object):
__tablename__ = 'reading'
id = Column(Integer, primary_key=True),
date = Column(DateTime),
voltage = Column(Float),
value = Column(Float),
sensor_id = Column(Integer, ForeignKey('sensor.id'))
What I would like to achieve is something like:
sensor = Sensor(name='Bedroom Sensor')
dates, voltages, values = get_sensor_data_from_somewhere() #<-- This
returns three numpy arrays respectively of datetime, float, float types,
same len!
sensor.readings['date'] = dates
sensor.readings['voltage'] = voltages
sensor.values['value'] = values
session.add(sensor)
Is this possible somehow? It's similar to the attribute_mapped_collection,
but I need to map three different keys to the three attributes of the
Reading object.
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable
Example. See http://stackoverflow.com/help/mcve for a full description.
---
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.