Skip to content
Advertisement

Tag: sqlalchemy

SQLalchemy specify which index to use

Is there a way in SQLalchemy to tell the query which index to use? The reason I need this is that the SQL queries it generates use the “wrong” index – there exists an index for exactly the two fields that I have and it doesn’t use it. Thanks! Answer I think you can use with_hint() for this. e.g. Honestly,

RIGHT OUTER JOIN in SQLAlchemy

I have two tables beard and moustache defined below: I have created a SQL Query in PostgreSQL which will combine these two tables and generate following result: Query: However I can not create SQLAlchemy representation of it. I tried several ways from implementing from_statement to outerjoin but none of them really worked. Can anyone help me with it? Answer From

creating a temporary table from a query using sqlalchemy orm

I can create a temporary table this way: but the new table is unreadable because it says it has no primary key. existingtable.id is the primary key of exisitingtable, so I expected it to get the same treatment in the temp table. However, I would rather find some ORM way of doing this anyway. Given: How can I populate temp_table

How to query database by id using SqlAlchemy?

I need to query a SQLAlchemy database by its id something similar to but for id. How do I do this? [Searching over Google and SO didn’t help] Answer Query has a get function that supports querying by the primary key of the table, which I assume that id is. For example, to query for an object with ID of

Select NULL Values in SQLAlchemy

Here’s my (PostgreSQL) table — I want to select all people that are not known to be married, i.e., including those with NULL marriage_status. This does not work — Of course this does — The problem is that I’m accessing it from SQLAlchemy with — which gets translated to — And does not work — neither does — How should

Advertisement