Search code examples
pythonsqlalchemyalembic

Postgres refuses to find existing table, why?


I have a Postgres database and following tables inside of it, created using python Alembic ORM. Everything looks great at the first moment, but when trying to access any of the given tables, it throws: Did not find any relation named.

                    List of relations
 Schema |            Name             |   Type   |  Owner   
--------+-----------------------------+----------+----------
 public | CreditTransactions          | table    | postgres
 public | CustomerApplications        | table    | postgres
 public | CustomerApplications_ID_seq | sequence | postgres
 public | alembic_version             | table    | postgres
(4 rows)
\d CustomerTransactions

Result: Did not find any relation named "CustomerTransactions".

\d CustomerApplications

Result: Did not find any relation named "CustomerApplications".

How my tables look like:

from sqlalchemy import Column, Integer, Boolean, Float
from sqlalchemy.orm import declarative_base

Model = declarative_base()

class CreditTransaction(Model):

    __tablename__ = "CreditTransactions"

    ID = Column(Integer, unique=True, primary_key=True, index=True, nullable=False)
    customer_id = Column(Integer, unique=True, primary_key=True)
    bad = Column(Boolean, default=False)

class CustomerApplication(Model):

    __tablename__ = "CustomerApplications"

    ID = Column(Integer, unique=True, primary_key=True, index=True, nullable=False)
    email = Column(Integer, unique=True, nullable=False)
    annual_income = Column(Float, nullable=False)
    total_children = Column(Integer, nullable=True)
    age = Column(Integer, nullable=False)
    has_realty = Column(Boolean, default=False)
    has_car = Column(Boolean, default=False)
    has_mobile_phone = Column(Boolean, default=False)

Alembic Migrations seems to be okay, as I don't see any errors.

What in your opinion can cause this problem?


Solution

  • It turned out that for some reason my Postgres database do not recognize camel case table names. After giving corresponding lowercase names "applications" and "transactions" the error gone.