SQLAlchemy-Utils aggregated CompositeType

``` StatType = CompositeType( 'stat', [ Column('home', Integer), Column('guest', Integer) ] ) CardType = CompositeType( 'cards', [ Column('yellow',...

SQLALchemy-Utils: Use '~' operator with LTree

I am trying to query Postgres materialized path view(ltree) using Flask,SQLAlchemy-Utils and Flask-SQLAlchemy. SQLAlchemy-Util Docs shows the usage of '==', '!=' operators using LTree. How can i...

How to use SQLAlchemy Utils in a SQLAlchemy model

I'm trying to create a user model that uses UUID as primary key: from src.db import db # SQLAlchemy instance import sqlalchemy_utils import uuid class User(db.Model): __tablename__ =...

SQLAlchemy GUID Custom Type or SQLAlchemy-Utils UUID Type

While researching ways to implement UUID/GUID for table ID obfuscation, I've come across two methods of accomplishing this task but I'm having trouble differentiating between the two. The...

Using Flask-SuperAdmin With SQLAlchemy-Utils ChoiceType

I'm using SQLAlchemy-Utils's ChoiceType in my project. I have installed Flask-SuperAdmin. I have configured admin as below: admin = Admin(app) admin.register(models.MyModel,...

Column update not being commited in sqlalchemy (sqlalchemy-utils)

I have a User model and there is a password columns(PasswordType), amongst many other columns. When I try to do this user = # get some user with some query print(user.password) # there is a...

flask-sqlalchemy. PhoneNumber type

models.py class User(db.Model): id = db.Column(db.Integer, primary_key=True) Name = db.Column(db.String(80), nullable=False) # Phone = db.Column(), nullable=False) what kind of type...

SQLAlchemy-utils: create view "if not exists"

When I use the create_view () method of the sqlalchemy-utils module, everything works just fine the first time I run my script. However, every time after that first call, I encounter this error :...

How to mannualy decrypt a StringEncryptedType - SQLAlchemy-utils?

I'm building a report that uses some StringEncryptedType(String(), os.environ.get("SECRET_KEY"), AesEngine, "pkcs5") columns. For the sake of speed, I'm using text sql query to...

How to query by ScalarListType in SQLAlchemy-Utils?

The following does not work: from sqlalchemy_utils import ScalarListType class Company(db.Model): email_domains =...

How to set a non SQLAlchemy default type as utf8 bin

How can I set a non default SQLAlchemy type as utf8_bin, e.g: class User(sa.Model): __tablename__ = 'user' id = sa.Column(sqlalchemy_utils.UUIDType(binary=True), primary_key=True,...

SQLAlchemy: create_engine() error on deprecations.py

I want to ask why my create_engine error? my port was right, I tried it on my local, and it has nothing error from here. But, when I deployed it on my GCP, it got an error like this. My SQLAlchemy...

sqlalchemy.ext.automap: using PyInstaller (4.1, 4.2) results in KeyError ("sqlalchemy/util/_collections.py", line 212)

from sqlalchemy import create_engine from sqlalchemy.ext.automap import automap_base DB_PATH = "path/to/db.sqlite3" # SQLAlchemy engine =...

SQLAlchemy utils drop database statement cannot be used inside a user transaction

I have the code below which fails with the message from sqlalchemy_utils.functions import database_exists, create_database, drop_database url =...

Specifying a key for SQLAlchemy's `EncryptedType` at runtime

The SQLAlchemy-Utils documentation for the EncryptedType column type has an example that looks something like this: secret_key = 'secretkey1234' # setup engine =...

Why BINARY usage in SQLAlchemy with Python3 cause a TypeError: 'string argument without an encoding'

I read a lot of similar questions but none of the clearly answer my issue. I'm using sqlalchemy-utils EncryptedType on a mysql table column. The table creation and the insert is ok, but when I'm...

sqlalchemy fails to connect to ms sql server

Trying to connect to SQL server using SQLAlchemy with pyodbc(freeTDS) as the driver; The connections succeeds if I use pyodbc directly: >>> import pyodbc >>> conn =...

equivalent methods for tsvector_match and to_query in sqlalchemy_utils python package

I'm working on a migration of a Pyramid system from Python 2 to Python 3 that uses SQLAlchemy-Utils python package. The version of the target Python 3 is 3.6.9. In the module expressions.py there...

Why do I get no such table error when installing Apache Airflow on Mac?

It was so hard to put that right title. Ok, here it goes. I was following this tutorial to install Apache Airflow on my Mac (Mojave version)...

SQLAlchemy db.create_all() Error, not creating db

I am stuck at trying to create a db following a flask tutorial: https://www.youtube.com/watch?v=cYWiDiIUxQc&list=PL-osiE80TeTs4UjLw5MM6OjgkjFeUxCYH&index=4 I've unsuccessfully search for the...

CompileError: RETURNING is not supported by this dialect's statement compiler

I had a problem using sqlachemy with an insert statement. The insert statement does not return the inserted primary key. After a while I found the solution and it is to use the function returning....

How can I query a ScalarListType in flask_sqlalchemy

I want to insert an integer list as a one column datatype in flask_sqlalchemy, and I found ScalarListType in the package SQLAlchemy-Utils: from sqlalchemy_utils import ScalarListType class...

Trying to convert a LATERAL SQL query to SQLA ORM/Core API calls

I have name translations stored in JSONB fields with the format {lang-code: translation} (from sqlalchemy-utils). I'm using jsonb_each_text() for retrieving the names in a query. Below is my model...

Count related items in a sqlalchemy model using ChoiceType

This is a follow up to a previous question here. I'd like to count the number of offers, in each category, and output them in a format, which I can iterate in Jinja. new, 3 <br>used, 7 <br>broken,...

Flask SQLAlchemy Many to Many association object error

I am working on a project using python 3.4, Flask and SQLAlchemy that is based on project management. I have the following classes that need to be linked to each other in a many to many...

Error when accessing mysql database with sqlalchemy engine

I've created a database in mysql and I'm trying to access it via python, using sqlalchemy. Please see below: import mysql from mysql import connector from sqlalchemy import create_engine from...

SQLAlchemy AttributeError: 'int' object has no attribute '_set_parent_dispatch'

I happen to run into a problem which I've never seen before using sqlalchemy based on the same ORM schema. Here's a snippet of code. ```Python @contextmanager def session_scope(): """ provide...

SQLAlchemy KeyError when using both an index and a UniqueConstraint

When I include both a UniqueConstraint and Index in my table definition I get a KeyError. However, the error goes away if I specify UniqueConstraint alone or Index alone. I'm using...

sql alchemy Update resultset of raw query

Am new to Sql Alchemy. I have a raw sql which i need to execute by passing bind parameters. Resulting rows from the query, i need to update a particular column value. How do i do this in the...

Heroku error: sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not connect to server: Connection refused

app.py: from flask import Flask ,render_template,request,url_for,redirect from flask_sqlalchemy import SQLAlchemy import...