Category "sqlalchemy"

How to get query data converting foreign table's another column

I'm now using sqlalchemy, fastapi develop some REST API. And facing some problem to join multiple tables I have 2 tables as below [campaigns] class Campaign(Bas

fastapi using ORM not able to convert to pandas

I've been developing a fastapi way to query my database, instead of directly using SQL with pg. For some reason, I'm having issues converting the ORM query retu

`pd.read_sql(sql, engine)` raises NotImplementedError: This method is not implemented for SQLAlchemy 2.0

I tried to create a pandas DataFrame directly from my sqlserver database using an sqlalchemy engine: engine = create_engine(URL_string, echo=False, future=True)

Cannot create SQLAlchemy engine, getting error "loaded 'mysqldb' is not async"

I'm trying to replace Databases with SQLAlchemy 1.4 async. When I try to make the engine I get the following error: sqlalchemy.exc.InvalidRequestError: The asyn

Error with default value in enum field when define model class

Hello I have the following model: class Status(Enum): scheduled: 'scheduled' recording: 'recording' complete: 'complete' failed: 'failed' @dat

SQLAlchemy use calculated column

I want some code like below: distance = (Robot.pose_x)**2 + (Robot.pose_y)**2 robot_filtered = session.query(Robot).filter(distance > 100).all() But it give

Error: trying to push Table SQLAlchemy models to my production heroku-server using Alembic

I am trying to push my SQLAlchemy-models to create Tables in my heroku-postgres-database. I use this command: heroku run alembic upgrade head It starts to Run

Using asyncio extension with SQLite backend broken by version upgrade

An upgrade from SQLAlchemy version 1.4.0b2 to 1.4.0b3 results in the following error when attempting to connect to a SQLite engine, using the asyncio extension.

how to set up ORM models based on dataclasses

I have a bunch of dataclasses and want to use them as ORM Models for my database. To reach my goal i made decorator @sa_orm which maps each decorated dataclass

Flask API filtering posts by author

I've create CRUD API in Flask, but I have a problem with the filtering function returning books by a specific author. from flask import Flask, request, jsonify,

in many-to-many relationships, can you delete a row from one table without deleting any rows from the second table?

I am creating a database & working on CRUD functions. I've run into a problem with the Delete functionality. I have two tables, connected in a many-to-many

How to connect and query MySQL DB from python shell job in AWS Glue

I was using sqlalchemy to create connection and query mySQL DB, however, glue doesn't seem to support "sqlalchemy" or even "pymysql". Is there a way to do this

GeoPandas.GeoDataFrame: type "geometry" does not exist

Ubuntu 20.04.3 LTS (WSL2) fiona 1.8.21 geopandas 0.10.2 geopandas-base 0.10.2 geopy

psycopg2.OperationalError: could not translate host name "<address>" to address: Temporary failure in name resolution

I have looked through similar posts on SO and they seem to be specific to using Docker environments and haven't been much helpful. Ours is a little different, w

Table metadata transfer from sqlserver to postgresql using SQLAlchemy

I am trying to migrate my database from ms sql server to PostgreSQL using python script . Before migrating the data, script needs to create required tables. I i

Can I pass a dict to where() in SQLAlchemy?

Rather than selecting rows by a static set of columns, e.g. stmt = select(User).where(and_(User.first_name == 'foo', User.last_name == 'bar')) I would like to

AttributeError: __aenter__

I'm trying to make a bulk update in my database. Using aiohtpp + sqlachemy. I'm getting a error async with sess.begin(): AttributeError: __aenter__ with th

sqlalchemy.exc.NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:postgres

I'm trying to connect to a Postgres database with SQLAlchemy. I've installed psycopg2. However, I get the error sqlalchemy.exc.NoSuchModuleError: Can't load plu

SQLAlchemy: Using sessionmaker as contextmanger forces to expunge manually

I'm using SQLAlchemy and trying to use the sessionmaker as a context manager for my transaction (following the documentation): Session = sessionmaker(some_engin

Column Inheritance for Independent ORM Mapper Classes In SQL Alchemy

I am trying to replicate the following SQLite CREATE TABLE statements using the declarative ORM mapper classes in SQLALchemy. CREATE TABLE IF NOT EXISTS questio