I am trying to insert values name and dirname into mysql table using sqlalchemy. The value is the variable I fetch from previous looping function. My code is: #loop function to get the value for filenames in [file for file in inbound_files if ...
databaseanswers.net Latest Questions
In sqlalchemy asyncio, how could I insert a new dictionary into JSONB array column? Below is an example, where applications is the JSONB column name: applications = [{"id": 1, "title": "game"}, {id: 2, "title": "news"}] Also how to delete an existing dictionary ...
So… I have 2 classes: class Companies(Base): __tablename__ = 'companies' ticker = Column(String, primary_key=True) name = Column(String) sector = Column(String) class Financial(Base): __tablename__ = 'financial' ...
I need to create a database from within a Python/SQLAlchemy script, so to follow the safest practices I wanted to use query parameters (note: technically this would not be required, as the database name is hardcoded). So I wrote:
I have a calculated (computed) column in a table and would like to insert rows with the calculated column not specified with SQLAlchemy. However, the SQL query for insert generated by SQLAlchemy includes the calculated column. Is there a way ...
ENV: Python = 3.8.10 SQLAlchemy = 1.4.32 Pre: from sqlalchemy import select param1 = '1' What I need is achieving the SQL use SQLAlchemy SQL: SELECT t1.column_1 , t1.column_x FROM table_1 t1 INNER JOIN ( SELECT t2.column_2 , t2.column_3 FROM table_2 t2 WHERE t2.column_2 = param_1 ) AS ...
I am trying to use multiple schemas in SQLAlchemy. Somehow it does not work properly when using context manager (with-block) or try/except-block. This is my short execution example: def import_units(schema_name: str): from taxes.models import Tax ...
I’m using Python SQLAlchemy 1.4.xx to write changes to a database and last night I lost about 12 million rows across different tables, which hurts my soul. Before this morning I could access, manipulate, read, write, and other normal db ...
I cannot figure out how to set columns dynamically for filtering using the latest SQLalchemy style for ORM. Basically, I want to create a wrapper function to be able to pass in any columns into the ‘where’ part of the statement, ...
I am trying to test a simple async function which gets a user object from a postgres database when given an email address (get_user() in user.py below). The function itself works fine and the test was working too (test_get_user_one() in test_user.py). ...