0
votes
1answer
9 views

SQLAlchemy type containing strings larger than 4000 on Oracle using Varchar2

I am using Oracle database and in a certain column I need to insert Strings, which in some cases are larger than 4000 symbols (Oracle 11g limits Varchar2 size to 4000). We are required to use Oracle ...
0
votes
0answers
23 views

Long chained exists query with multiple one-to-many mappings in the chain

Edit: Following piece seems to be the right way: session.query(User).join("userGadgets", "gadget", "components","gadgetComponentMetals") Original: I have the following tables configured: class ...
1
vote
1answer
31 views

How can I rank entries using sqlalchemy?

I have created a model User that has the columns score and rank. I would like to periodically update the rank of all users in User such that the user with the highest score has rank 1, second highest ...
0
votes
1answer
16 views

Insert and update with core SQLAlchemy

I have a database that I don't have metadata or orm classes for (the database already exists). I managed to get the select stuff working by: from sqlalchemy.sql.expression import ColumnClause from ...
0
votes
1answer
19 views

SQLAlchemy, Flask: get relationships from a db.Model

I need to get a list of a model's properties which are actually relationships (that is, they were created by relationship()). Say I have a model Foo in a models: class Thing(db.Model): id = ...
0
votes
1answer
17 views

Exception Handler Not Working: Commiting to SQL Database with SQLAlchemy in Python

I am trying to commit entries to a MySQL database using SQLAlchemy in Python. The function below was meant to allow me to commit a batch of entries, even if one or two of them contained errors that ...
0
votes
1answer
21 views

sqlalchemy.orm.exc.UnmappedInstanceError in flask

I have been reading the SQLAlchemy docs, but I don't understand them. The error (UnmappedInstanceError) says something isn't mapped. What isn't mapped? I really don't get sqlalchemy and I want to go ...
1
vote
1answer
37 views

SQLAlchemy insert, update precondition (consistency check)

I would like to keep an invariant when inserting into or updating an 'interval' many-to-many relation using SQLAlchemy. The goal is to make sure that there are no overlapping intervals in the table ...
0
votes
1answer
27 views

Multiple databases in Pyramid

Firstly, I'm new to Python. Now that that's out of the way. I'm trying to access data on 2 different databases and display information on one view. ...
0
votes
2answers
20 views

Remove objects from sqlalchemy session

I have a portion of the code which does the following: get the data from the database perform an API call to one server perform another API call to another server store the results in the database ...
0
votes
1answer
16 views

SQLAlchemy: Effect of 2 session objects?

Will the following use 2 DB connections from the connection pool because of the useage of 2 session calls? users_from_contacts = db.session.query(User).join(Email, Email.user_id == ...
0
votes
1answer
17 views

Sqlalchemy relationship to built-in type

I have something similar to this: class Item(Base, DBBase): __tablename__ = 'item' id = Column(Integer, primary_key = True) name = Column(String), nullable = True) comments = ...
0
votes
1answer
27 views

SQLALchemy custom integer sort order

I have a table with a column of integers that represent the type of the row. These integers range from 1 - 5. How do I specify a custom sort order in SQLAlchemy, for example if I want the rows sorted ...
2
votes
1answer
29 views

Error in SQLAlchemy with Integer: “object() takes no parameters”

I suddenly started seeing an error in my Python SQLAlchemy application and I can't figure out what's causing it. My code looks like this: from sqlalchemy import create_engine from sqlalchemy import ...
0
votes
0answers
20 views

SQLAlchemy load_only and defer

I have tried using the SQLAlchemy methods load_only and defer to send only certain columns from the database, but I can't seem to get them to work. Here is the code I am using: query = ...
0
votes
1answer
25 views

how to insert a dictionary with sqlsoup

I am trying to insert a dictionary with sqlsoup. Unfortuntely this doesn't work: db.blah_table.insert({"blah_field" : "blah_value"}) it gives me an error TypeError: insert() takes exactly 1 ...
0
votes
0answers
17 views

SQLAlchemy problems when using very long connection string

I'm using a connection-string/DSN with a really long hostname. SA seems to not like it. I've sanitized the error/trace, below. Debugging is made difficult by the fact that this error is raised within ...
1
vote
1answer
35 views

Converting string to date timestamp in SQLAlchemy

I have a database table, which I am accessing through SQLAlchemy. Each row is timestamped, but unfortunately it isn't simply a column with a DATE type. It is timestamped with two columns. One is the ...
0
votes
1answer
18 views

Select partial entities with specific columns

In SqlAlchemy, I need to fetch partial entities with the given list of fields. Other answers suggest to do any of the following: session.query(User.id, User.login).all() ...
0
votes
0answers
35 views

Safe relational query language for public use via the API

I'm developing an API which, among other features, provides CRUD access to the PostgreSQL storage. I need to expose some SQL features such as: Projection (pick/omit fields in the result set) ...
3
votes
2answers
31 views

Query to check if size of collection is 0 or empty in SQLAlchemy?

Person has one Building. Person has many Group I want to return all of the people from a certain building who do not have any Group in their groups collection. Maybe I can search by people who have ...
0
votes
0answers
20 views

How to append a FromClause to a Select by joining on SQLAlchemy

I'm constructing accumulative selects. For example: from sqlalchemy import sql query1 = sql.select( [table1, table2], from_obj=table1.join(table2, table1.c.id == table2.c.fk)) # Do things ...
0
votes
1answer
26 views

Delayed change using sqlalchemy

I'm facing a strange behaviour in multi-process environment. My first process (later called P1) writes to db through sqa. My second process (later called P2) reads from db through sqa. This second ...
1
vote
0answers
21 views

Alembic support for multiple Postgres schemas

How can I use Alembic's --autogenerate to migrate multiple Postgres schemas that are not hard-coded in the SQL Alchemy model? (mirror question of SQLAlchemy support of Postgres Schemas, but for ...
0
votes
0answers
19 views

Separate session objects for separate REST requests in SqlAlchemy?

I am using sqlalchemy (with MySQL as database) with cherrypy. I have created an engine which is application-wide. I read from SqlAlchemy Sessions Doc that sessions are not thread-safe. Does that mean ...
0
votes
0answers
33 views

Storing UTC timestamps in Postgresql to later be displayed with AngularJS

I have read quite a bit on storing timestamps in UTC and keeping the timestamps in UTC until the last possible moment (i.e. when it is displayed to the user in the browser). However, I am still a ...
1
vote
1answer
84 views

Sqlalchemy sometimes can not get data

I have a database named weixin_db and there is a table named nvi_instance in it. This is detail : mysql> desc instance; +--------------+------------------+------+-----+---------+----------------+ ...
1
vote
1answer
21 views

Dynamically query a subset of columns in sqlalchemy

Assume only two columns(name and id) are needed from a table. I would code something like below: session.query(User.id, User.name).all() But if the column names are dynamic, def get_data(table, ...
0
votes
1answer
16 views

how verify if sqlalchemy session is configured?

standard/normal configuration of sqlalchemy session: from sqlalchemy.orm import scoped_session, sessionmaker DBSession = scoped_session(sessionmaker(extension=ZopeTransactionExtension())) # 0 ...
0
votes
1answer
26 views

Adding an object to a one-to-many relationship in Pyramid, SQLAlchemy

I have set up a simple system for adding comments to items in my database using a one-to-many relation (one item can have many comments), but I can't seem to get it to work. It should be simple, I ...
1
vote
1answer
30 views

Prevent touching db during unit testing with SQLAlchemy

I've been using Django for several years, but have recently decided to try out Flask for a new API. Thanks to Carl Meyers excellent presentation on testing Django at PyCon, I've been using the ...
0
votes
1answer
50 views

SQLAlchemy - 'Table' object has no attribute 'datetime'

I'm getting the following error on the code below. I'm not seeing the point where table/object is returned, or at least should be. Any other pointers would be welcome too. I run ...
1
vote
1answer
13 views

Why is my scoped_session raising an AttributeError: 'Session' object has no attribute 'remove'

I'm trying to set up a system that elegantly defers database operations to a seperate thread in order to avoid blocking during Twisted callbacks. So far, here is my approach: from contextlib import ...
0
votes
0answers
15 views

why sqlalchemy model instance doesn't update after updated instance '__dict__' and committed

I am using sqlalchemy and update model instance __dict__ to for update record, bud doesn't work #user is a model instance queried from database vars(user).update(**update_dict) ...
3
votes
0answers
34 views

Is this an acceptable way to make threaded SQLAlchemy queries from Twisted?

I've been doing some reading on using SQLAlchemy's ORM in the context of a Twisted application. It's a lot of information to digest, so I'm having a bit of trouble putting all the pieces together. ...
1
vote
1answer
9 views

How to set client_flags of FOUND_ROWS in SQLAlchemy with mysqlconnector to return affected rows

I am trying to change the behavior of ResultProxy.rowcount attribute for SQLAlchemy. The configuration is mysql+mysqlconnector. I am setting connect_args = {'client_flags': [ClientFlag.FOUND_ROWS]} in ...
3
votes
0answers
35 views

SQLAlchemy get value from a table if not present in another one

i'm trying to do the following: class Property(Base): name = Column(String(50)) default_value = Column(String(50)) class AssociatedProperty(Base): property_id = Column(Integer, ...
1
vote
0answers
27 views

How can I compare SQLAlchemy UTC dates in the user's timezone?

I'm trying to fetch events to display on a calendar in the user's local time. All dates are stored in Postgres as UTC. Here's the Event model and the query in question, from datetime import ...
0
votes
1answer
22 views

Why can't I run a query against my has many relationship in SQLAlchemy?

I have a table called Group which has many Person through groups_people. This is that part of the Group table: class Group: ... ... people = db.relationship('Person', secondary=groups_people, ...
1
vote
1answer
21 views

Alembic --autogenerate fails for me

The command I'm running: alembic -c development.ini revision --autogenerate -m "test" I get the following result: Traceback (most recent call last): File ...
1
vote
0answers
28 views

SQLAlchemy get SQL INSERT statement

Is any way to get INSERT/UPDATE statement before commiting? I mean if I create object order = Order(qty=1, comment='ccc') session.add(order) I'd like to get INSERT INTO "Orders" ("qty", ...
0
votes
1answer
24 views

Using a separate PasteDeploy file for sqlAlchemy urls with cryptic passwords

I have a Pyramid application I am working on. I, ideally, need the ability to put the sqlalchemy url settings into a separate file, and then consume this file on the engine_from_config file. By ...
0
votes
0answers
19 views

Lists from columns from SQLalchemy ResultProxy object

I execute a query like this: query_result = engine.execute(SQLQUERY) and the result is a ResultProxy object. I want two lists corresponding to two columns A and B in the result. I can do this as ...
0
votes
0answers
28 views

Sqlalchemy get data after a long time

In openstack , I use below code to store IP address successfully : ''' Now, just insert randomly IP v4/v6 address ''' from horizon.conf import nvi_db nvi = nvi_db.Nvi_Instance() guest_uuid = ...
2
votes
0answers
65 views

How to populate lists of objects with WTForms?

Use case: using a form to enter grades for each course a student is enrolled in. Model: Using SQLAlchemy, I defined a Student object, a Course object, and a StudentCourse association object that ...
0
votes
2answers
25 views

sqlalchemy's UnicodeText column is giving me a str on my MySQL table; shouldn't it be unicode?

Let's say I have a simple table: class MyTable(...): __tablename__ = 'my_table' id = ... unicode_col = Column(UnicodeText()) Now I would like to get some data out of it: assert ...
0
votes
1answer
40 views

SQLAlchemy first() without executing expression

I can't imagine, how to convert this SQL code to SQLAlchemy statements: SELECT TaskID FROM TaskPushes p WHERE PushToEmployeeID = 5 AND PushDate = ( SELECT TOP 1 PushDate FROM TaskPushes ...
0
votes
2answers
38 views

Is there a Non-Sqlalchemy way to deal with many-to-many relationships in Python?

I've searched for quite a long time on the web for a method that deals with many-to-many relationships in python sqlite3, but all seems to lead to Sqlalchemy. I'm not against using sqlalchemy at ...
0
votes
1answer
28 views

Multiple foreign keys in one column referencing the same table

I have a table called "Subtests" and a table called "TestSteps" (in a sqlite db using SQLalchemy) and I would like to allow for test steps to be shared amongst multiple subtests. This requires storing ...
0
votes
1answer
62 views

Flask-SQLAlchemy many to many join condition

I have 3 tables, Events, Invites, and Proposals. I would like to be able to query for events.invites and return a query of all invitees (and be able to get user's info from my user table, like ...

15 30 50 per page