Relative Content

Tag Archive for pythonsqlalchemy

Can I implement a custom insert method in a SQLAlchemy ORM-mapped class?

I have an ORM-mapped class Data which includes a ‘valid_until’ (datetime) attribute I use for versioning of rows. This means that rows in the table can be duplicates with respect to some attributes, but the ‘valid_until’ attribute sets them apart, allowing me to identify which one is the most recent. The most recent such row has a future “infinity” ‘valid_until’ and all previous rows have the ‘valid_until’ set to when they were superseded.

Can I implement a custom insert method in a SQLAlchemy ORM-mapped class?

I have an ORM-mapped class Data which includes a ‘valid_until’ (datetime) attribute I use for versioning of rows. This means that rows in the table can be duplicates with respect to some attributes, but the ‘valid_until’ attribute sets them apart, allowing me to identify which one is the most recent. The most recent such row has a future “infinity” ‘valid_until’ and all previous rows have the ‘valid_until’ set to when they were superseded.

How to add data for multiple objects in one row with sqlalchemy

I am performing a regular web scrape for laptop prices with Beautifulsoup. The data from these searches I want to put in a data base with Sqlalchemy. But for each search I want to add just one row, with the date of the search, and a new price for each of the 15 laptops (the laptop names are the names of the columns). I cannot figure out how to do this, your help is appreciated.