Questions tagged [sqlalchemy]

SQLAlchemy is a Python SQL toolkit and Object Relational Mapper that gives application developers the full power and flexibility of SQL.

Filter by
Sorted by
Tagged with
0
votes
0answers
8 views

Python Sqlalchemy Encrypt Datasource Conection

I have app using flask + sqlalchemy, but my datasource config are in text plain. Is possible encrypt it? Java have a keytool, for python + sqlalchemy have some way to do it ?? tks
0
votes
0answers
7 views

Mutually referencing class deadlock

I have two SQLAlchemy class declarations that refer to each other so the first one gives an error because the second one is not yet declared. The records in Key with key_type_id == 4 are references ...
0
votes
0answers
7 views

custom exception message in sqlalchemy

Im trying to raise a custom exception message when I get an exception but I get the following error - try: query_start_time = time.time() execute_sql_alchemy_query except Exception as ex: ...
0
votes
0answers
16 views

Stop query execution if count is more than N in postgresql/sqlalchemy

Is there any way to stop the query if count is greater than any number lets say N=50 in postgresql/sqlalchemy, like COUNT STOPKEY in oracle. Thanks
2
votes
1answer
33 views

Saving numpy integers in sqlite database with sqlalchemy

I want to save data from a pandas DataFrame to a sqlite database with sqlalchemy. (I know I can use pandas' .to_sql, but I found it easier to use sqlalchemy directly if something did not work properly....
0
votes
0answers
32 views

Importing table in postgresql table Schema return empty datatable

I have this code Pandas writing data frame to another PostgreSQL schema. It seems that from Pandas 0.15 version, it can be imported in a selected Postgresql Schema. Setting schema for all queries of ...
-1
votes
0answers
15 views

Flask-sqlalchemy reflection. Doesn't reflect constraints

I have a Flask application with a dynamical count of tables. And I do a reflection of these tables tables.query.all() - the list of available tables I do a loop over the list of tables and get class ...
-1
votes
0answers
19 views

SQLAlchemy + sqlserver +temp table [on hold]

How to create temp table using SQLAlchemy and insert the data from pandas data frame and then use it in join. I have engine object with me
-1
votes
1answer
43 views

How do I force SQLAlchemy to convert attribute values when I construct a new instance of a model?

If I have a model class MyModel: my_int_val = Column(INTEGER(10, unsigned=True)) How do I force SQLAlchemy to convert my_int_val to an integer without having to load the object via query. E.g. ...
-1
votes
0answers
13 views

Quickly return results from a search over SqlAlchemy DB

So I have "threads", which each belong to an "org". i want to show users the per-org thread counts. However, users can search by many different slices, and for each slice I want to be able to quickly ...
-2
votes
1answer
36 views

Updating sqlalchemy with boolean value from form [on hold]

I'm trying to update a row in a database table with a value from a wtforms BooleanField. When creating the row, it's inserted into the database with no problem, but when updating I get the error below....
1
vote
0answers
50 views

How do I convert a geography column to latitude and longitude?

I am using PostgreSQL, SQLAlchemy and GeoAlchemy2 libraries to store some geospatial coordinates in the database. I define the database column in my database as follows using Python: import ...
1
vote
1answer
26 views

ORM sqlalchemy create schema set column equal to calculation

In sqlalchemy ORM, is there a way to set a column equal to a calculation from other two columns? This would be similar to what MySQL generated columns.e.g.: class FactStockQuantity(Base): ...
0
votes
1answer
26 views

SQLAlchemy: MySQL column DDL with GENERATED ALWAYS AS

I'm trying to replicate this column with sqlalchemy orm (MySQL): `line_price_taxed` decimal(20,4) GENERATED ALWAYS AS ((`quantity` * `unit_price_taxed`)) STORED, my attempt so far has been: ...
0
votes
0answers
12 views

Google Dataflow pipeline executes code locally when runner is DataflowRunner

I have a dataflow python script: from __future__ import print_function import argparse import logging import apache_beam as beam import subprocess import sys from pycloudsqlproxy import connect as ...
0
votes
0answers
18 views

Filter attributes with OR and AND from multiple joined tables in SQLALCHEMY produces extra entity

As mentioned in the documentation, sqlalchemy "filter" and "filter_by" filters only "the last entity that was the target of a call to Query.join()" I want to have a query like: SELECT sale.* FROM ...
0
votes
0answers
15 views

SQLAlchemy ORM relationships on partial foreign keys

I have two sql tables: CREATE TABLE project ( id UUID PRIMARY KEY, recording_id UUID ); CREATE TABLE recording ( id UUID, t DATETIME, value FLOAT PRIMARY KEY (id, t) ); The database is ...
0
votes
0answers
24 views

Sqlalchemy inserting “?” in where clause

I am using the Query API in sqlalchemy. I do not have an object mapping. In all filter clauses, sqlalchemy will create a statement with "?". For example session.query(table).filter(table.c.foo == 1) ...
0
votes
1answer
21 views

How to implement value conversion during field comparison operations, in the column type SqlAlchemy (or another class)?

There are many fields (10+) in different tables, whose logic needs to be encapsulated in the type implementation. For example: upper for string. import sqlalchemy as sa class UpperString(sa.String): ...
1
vote
1answer
27 views

sqlalchemy to filter on list by table name and filers condition

I am using sqlalchemy ORM layer to communicate with RDS. Here this is common function for all tables to filter row. We pass table name, column to select, filters and date range. filter = { "...
0
votes
0answers
24 views

Python SQLite3 export last hour of data

i am trying to export the data from my SQlite Database in frequency of every hour. So basically my code runs fine at the beginning of every second of every hour but it will export everything in db. ...
0
votes
0answers
19 views

Using SQLAlchemy `and_` with MagicMock

I have a SQLAlchemy call that I am trying to mock. Model.query.filter(and_(Model.id.in_(some_ids), Model.other_id != None)).all() I am using MagicMock to mock this call and give it a return value. ...
2
votes
0answers
24 views

sqlalchemy.exc.DatabaseError: (cx_Oracle.DatabaseError) DPI-1047: Cannot locate a 64-bit Oracle Client library

We have an oracle database and i am trying to connect to oracle database using python in linux. We have installed "sqlalchemy" , "cx_Oracle" libraries. When i try to execute the below python script, ...
0
votes
1answer
26 views

Python SQLAlchemy not returning column names in results

Very basic table, basic query. My table has these 5 columns: project_id, name, job, status, state I wish to query all names related to a specific project_id. I am receiving a tuple as the result ...
0
votes
1answer
32 views

How to make SQLAlchemy hybrid_property select expressions work for both select and filter

I've been attempting to write some expressions with hybrid properties, but I've found them to be extremely limited and I'm wondering if I can get around those limits. Basically, I've found they ...
1
vote
2answers
66 views

Flask-Sqlalchemy: Table with 3 primary keys that are also foreign keys

I am trying to translate a table from pure SQL to Flask-Sqlalchemy, but the documentation available is not clear about how to do this specific scenario - Primary keys that are also foreign keys. The ...
0
votes
0answers
34 views

Is there a way to pass a nan value as null from a Pandas dataframe to a table in an Oracle database using SQLAlchemy?

I am attempting to merge values from a pandas dataframe into a table within an Oracle database using SQLAlchemy. The table has 137 columns, and some entries within the columns contain no value (...
0
votes
2answers
63 views

'QVCI feature is disabled' ERROR when using existing Teradata Database to define models for use by flask app

In attempting to build my flask application around an existing Teradata Database, I have run into an issue defining the db models to be used by my application from this existing database. I am getting ...
0
votes
0answers
60 views

Flask SQLAlchemy throws Unicode error in WSGI server, but not in debug local server?

I have made a test table in flask-sqlalchemy that stores a bunch of file paths in a Unicode column in a sqlite3 database. Many of these file paths have characters that are outside utf-8. If I am ...
1
vote
1answer
32 views

how to handle ever-changing password in sqlalchemy+psycopg2?

I inherited some code that uses sqlalchemy with psycopg2, which needs to run on AWS. RDS Postgres supports iam-based authentication, but the way it does it is rather kludgy: you request a temporary ...
-2
votes
0answers
20 views

Postgresql + Python Live Data fetch [on hold]

Can someone help me? 1) I have postgres database which is getting updated every second with live data through python script. Now, 2) I want to fetch that live data from postgres after every 30 ...
0
votes
0answers
41 views

Flask-SQLAlchemy with pyodbc, how to set encoding in connect string

I am using Flask-SQLAlchemy and pyodbc as a connect driver. My connect string: SQLALCHEMY_DATABASE_URI = 'mssql+pyodbc://{user}:{password}@{host}/{name}?driver={driver}&charset={charset}'.format( ...
-1
votes
0answers
34 views

SQLAlchemy takes too long from retrieval data from Amazon RDS

I'm developing a Flask web application and i recently deployed this app on Heroku and connected it with a AWS-RDS. The logic application is working fine, except that i have noticed that sometimes the ...
1
vote
1answer
17 views

What user permissions are needed to reflect an Oracle Database?

I am trying to create a read-only user for an Oracle 11g Database that will be used by SQLAlchemy to query the database. I was using an existing DBA user with SQLAlchemy and wasn't having any problems,...
0
votes
0answers
21 views

How to automap a backend-agnostic Base in SQLAlchemy

I am trying to take a simple database schema in Oracle and migrate it to a mssql database. There are other ways I can do this but my first thought was to utilize SQLAlchemy's automap and create_all ...
0
votes
0answers
32 views

Are sqlalchemy docs wrong?

I have wasted several hours on a bug which is probably now solved, and believe it may be from the docs being wrong. So on this page: https://docs.sqlalchemy.org/en/13/orm/session_basics.html it tells ...
0
votes
0answers
18 views

Does SQLAlchemy support Firebird 3 yet?

Does SQLAlchemy support Firebird 3? I ask because when using the below model, SA seems to not create the expected DDL (or metadata, not sure of the correct term) for the intended primary key id. ...
0
votes
0answers
24 views

SQLAlchemy secondary relationship not using JOIN

I created a Many to Many relationship on SQLAlchemy, but for some reason when I access it it's not emitting a JOIN clause, but rather selecting from a cross product of the three tables and filtering ...
0
votes
0answers
26 views

How can I connect 3 databases (MySQL) with several tables using sqlalquemy and jupyter notebook?

I have 3 mysql databases (2007, 2008, 2009), everyone of them has different tables inside (11 tables, 14 tables, 20 tables), I am trying to create just one dataframe from all 3 databases with just the ...
0
votes
0answers
26 views

SQLAlchemy Query returns truthy on empty MySQL set

I'm using al SQLAlchemy query to fetch data from a MySQL table and render it in an HTML Table via Flask/Jinja. When my table is empty, Flask/Jinja should not create the HTML table but instead, show a ...
0
votes
0answers
23 views

Could I create a mutually referenced sqlalchemy classes across multiple files

How to create sqlalchemy mutual referencing classes across multiple files? I have been searching for examples all over the web, but most of the examples put mutual referenced classes in one single ...
1
vote
2answers
45 views

“This transaction is closed” after rollback

I'm trying to do some schema changes inside a transaction manager provided by pyramid. I'm running into various issues trying to run commit after a rollback: The simplified version is: def ...
0
votes
0answers
18 views

Alembic how to fix empty migration [duplicate]

I already have a database without Alembic and i try Alembic to handle migrations. When i use alembic revision --autogenerate -m 'init migration' i have emty migration script like from alembic ...
-3
votes
1answer
29 views

How does sqlalchemy's filter() implement incoming arguments such as >= and <= to enter and generate SQL statements? [closed]

I want to create my own mysql's ORM,but when I write the search method,I have some questions about the sqlalchemy that how to get the '<='\'>='\'!=' expression into the method now I can just ...
0
votes
0answers
22 views

Airflow + sqlalchemy short-lived connections to metadata db

I deployed the latest airflow on a centos 7.5 vm and updated sql_alchemy_conn and result_backend to postgres databases on a postgresql instance and designated my executor as CeleryExecutor. Without ...
1
vote
0answers
23 views

What is direction of many to many bidirectional?

I have a "many to many" bidirectional, but when I create mapping data for Group and User, it's only working with 1 direction. class Groups(db.Model): __tablename__ = 'GROUPS' grpid = db....
-1
votes
0answers
14 views

How to fix sqlalchemy.exc.OperationalError [closed]

I installed flask-migrate and did a db init, migrate and upgrade for the project I am working on but after doing the migrate and upgrade to add in a new table which I already coded into my models.py, ...
0
votes
0answers
21 views

SQLAlchemy Bulk update with custom where clause

using bulk_update_mappings, the approach is: All those keys which are present and are not part of the primary key are applied to the SET clause of the UPDATE statement; the primary key values, ...
1
vote
1answer
34 views

MySQL multiple table UPDATE query using sqlalchemy core?

I want to update two tables using one query. I'd like something along the lines of this UPDATE tblReceipt, tblReturn SET tblReceipt.ReturnedDate = tblReturn.CreatedDate, tblReturn....
3
votes
2answers
35 views

How to join 2 tables and get the result as on object

I want to join two tables with SQLalchemey. class Transaction(db.Model): __tablename__ = 'transaction' id = db.Column(db.Integer, primary_key=True, autoincrement=True) user = db.Column(...