Going Back to Basics In models.py: “”” Basic Product Category models using reference from: https://docs.sqlalchemy.org/en/14/orm/relationship_api.html#sqlalchemy.orm.relationship “”” from sqlalchemy import Column, ForeignKey, Table, Integer, Boolean, String from sqlalchemy.orm import declarative_base, relationship Base = declarative_base() category_products = Table( “category_products”, Base.metadata, Column(“product_id”, ForeignKey(“products.id”), primary_key=True), Column(“category_id”, ForeignKey(“category.id”), primary_key=True), ) class Products(Base): __tablename__ = “products” id = Column(Integer, primary_key=True) label […]
Python Implicit Namespace Packages
A very confusing topic is python imports and paths. One area that makes it more confusing was the introductions of implicit namespace packages. https://peps.python.org/pep-0420/#differences-between-namespace-packages-and-regular-packages These are packages that are found even without an __init__.py. A folder can be created on the python path and that folder automatically becomes a python package. Not sure why or […]
Postgres: Querying Arrays
Quering tables that contain arrays can be tricky in postgres. The Postgres docs: Array functions provide a good explanation but it is good to practically run the queries and see the results. There is documention about arrays in general from postgres. Caveats: Array Types An important thing to note is that arrays being compared need […]
The city of Joburg is again rerating the market value of properties in the City. The previous time this was done was in 2018 – where rate increases became effective July 2018. Use the objections.joburg.org.za website to object. The deadline for objecting is end of March 2023. The userguide on how to object is on […]
There is a use case where about 10000 records are inserted every few seconds after some processing. There was a suggestion that dropping indexes before the data insert would improve the speed of the inserts. The postgres docs recommend removing the indexes and foreign keys. Creating an index on pre-existing data is quicker than updating […]