0
votes
1answer
7 views

How to update a relationship when another field is modified in SQLAlchemy

I have a simple Client model in SQLAlchemy, using mostly declarative. This model has a name field and has a many-to-many relationship with a MetaphoneCode model. The code goes like this: class ...
0
votes
1answer
11 views

Sqlalchemy order by calculated column

I'm trying to build a select query using sqlalchemy, but I need to sort the results by a calculated value and I'm not sure how to do it. Basically, I have a 'start_time' and 'end_time' columns and I ...
0
votes
1answer
28 views

Combining PostgreSQL Enum with a TypeDecorator

I want to have an Enum type that automatically lowercases input before saving it in a PostgreSQL 9.x database. This first code block accomplishes that, but, unlike a normal Enum, the specific ...
0
votes
2answers
52 views

Python, Flask + SQLAlchemy - query not working

I've got the following Python code app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql+psycopg2://my_user_name:@localhost:5432/my_db' db = SQLAlchemy(app) ...
1
vote
1answer
15 views

sqlalchemy nested inheritance / polymorphic relationships

I have a tree that looks like this, reflected via polymorphic inheritance: A / | \ B C D That works great, like: class BaseModel(db.Model): # Table A in diagram ...
1
vote
1answer
21 views

SQLAlchemy, eager loading on object refresh

If have following ORM setup in SQLAlchemy: class Foo(Base): id = Column(Integer, primary_key=True) status = Column(String) barId = Column(Integer, ForeignKey("bar.id")) bar = ...
0
votes
1answer
16 views

SQLAlchemy complex many to many with abstractions

We have this pattern in our very complex database which essentially boils down to a directed graph with metadata on each edge. We're solving it, but I'm sure there is a "better" solution. I'm going to ...
1
vote
0answers
22 views

MySQL (mariaDB) Connection Error with SqlAlchemy

Hello I have a mariaDB database on a Ubuntu server running in a virtual box. With 'Sequal Pro' i can connect without any problems (with the ssh option). Port forwarding like this: HOST 127.0.0.1 3306 ...
1
vote
0answers
13 views

sqlalchemy literal text added to an insert

I'm trying to get sqlalchemy to accept some more complex behavior on an insert, and can't figure out the idiomatic way to do it. To simplify things, I was just trying to add a literal string to the ...
2
votes
0answers
18 views

Camelot for Desktop Application

I am developing a GUI application in Python and have already used SQLAlchemy for database interactions. I was going to use PyQt for the GUI development and then came across the framework Camelot. I ...
0
votes
0answers
21 views

SQLAlchemy and selecting on datetime column

I have declared a table using SQLalchemy like so: Database.engine = create_engine('sqlite:///file.db', echo=True) Database.metadata = MetaData() Database.metadata.bind = ...
0
votes
0answers
46 views
+50

UnboundExecutionError from SQLAlchemy in Cherrypy project using Nginx with uWsgi

I am currently using SQLAlchemy as ORM in my Cherrypy project. The error that I have does not occur while I am on my cherrypy enbedded webserver, but ONLY from my Nginx deployment. On Debian Wheezy ...
6
votes
1answer
73 views

Find out what's going to be deleted

When using more complex, hierarchical models with differing settings on how cascade deletes are handled it gets quite hard to figure out beforehand what a delete() will exactly do with the database. ...
1
vote
1answer
72 views

Oracle database schema using SQLAlchemy

I have a problem with SqlAlchemy. When I define the schema in my Oracle database, foreign keys are not recognized in other tables. Tested without using layout and it worked. But I need to define the ...
1
vote
1answer
19 views

How to dynamically create classes inside a module-level initialize() method in Python

I'm writing a library to talk to a database using SQLAlchemy. I really like SQLAlchemy's autoload_with=engine feature, which can be passed to the Table constructor to grab all of the table's columns ...
0
votes
1answer
18 views

Issue with multiple sessions

In my application I'm using SQLAlchemy for storing most persistent data across app restarts. For this I have a db package containing my mapper classes (like Tag, Group etc.) and a support class ...
3
votes
1answer
19 views

Is there a way to perform a join across multiple sessions in sqlalchemy?

If I have multiple sessions to different databases, is there a way to perform a join across them in one query? For instance, I'm integrating two programs, with a table in the middle to translate id's ...
0
votes
0answers
22 views

Alembic detects changes but produces empty migration with --autogenerate

I'm trying to get alembic working auto-producing migrations with the --autogenerate flag. When I run alembic -n mydbname --autogenerate -m "my message" I get something like: INFO ...
0
votes
1answer
38 views

Error flask-sqlalchemy NameError: global name 'joinedload' is not defined

I'm trying to use a sqlalchemy loading strategy to speed up my queries. After reading this I realized that I was making the mistake of looping through the records in my template. The only problem is ...
0
votes
2answers
31 views

SQLAlchemy variable relationship

I'm unclear on how to configure SQLAlchemy for the following scenario: Several tables of varying nature. All tables need to reference a one-to-many notes table Would like to only have one notes ...
0
votes
0answers
19 views

sqlalchemy undefined Table

Not sure why, but I get NameError: name 'Table' is not defined with the following code. Anyone have any idea? from sqlalchemy import create_engine, MetaData class Boo: engine = ...
0
votes
0answers
30 views

Debianize SQLAlchemy using python-stdeb & dpkg

I am trying to build a .deb package for sqlalchemy, using the python stdeb builder. Respecting the python stdeb usage I use the following instructions: wget ...
3
votes
1answer
43 views

Override the __eq__ operator in sqlalchemy

I'm working with declarative base SQLAlchemy. I'm in need of a string column that can be nulled but not have the NULL != NULL problem that comes along with databases. So I've written a custom ...
1
vote
1answer
55 views

sqlalchemy bulk update performance problems

I need to increment values in a column periodically with data I receive in a file. The table has > 400000 rows. So far, all my attempts result in very poor performance. I have written an experiment ...
0
votes
1answer
41 views

should SQLAlchemy session.begin_nested() be committed with transaction.commit() when using pyramid_tm?

I'm developing a pyramid application and currently in the process of moving from sqlite to postgresql. I've found postgresql more restrictive transaction management is giving me a bad time. I am ...
0
votes
2answers
26 views

sqlalchemy does not enforce foreign key constraing

I am trying to play with the sql alchemy ORM based db definition. I have defined my tables as follows class Customer(Base): __tablename__ = 'customer' id = Column(Integer, ...
1
vote
0answers
39 views

Where are the python-native objects for SQL-Alchemy?

In an ORM I would expect to be able to do this: session.add(Lake("hello",Polygon([(0,0),(1,0),(1,1)]))) lake = session.get(Lake).first() assert isinstance(lake.geometry, Polygon) assert ...
0
votes
2answers
47 views

py2exe [ImportError: No module named sqlalchemy]

I installed sqlalchemy-0.8.1 in my win7 via 'setup.py install' and "import sqlalchemy" works well But when I want to pack my files with py2exe, error occurs ImportError: No module named sqlalchemy ...
-2
votes
0answers
20 views

postgresql.CIDR and sqlalchemy [closed]

SELECT net FROM nets WHERE net >> '10.0.0.0/8' How to convert this sql-code to sqlalchemy? 'net' has type CIDR in postgres. Is it possible?
0
votes
1answer
26 views

Retrieve distinct backref instances from SQLAlchemy query

Given the following models: class Foo(db.model): id = db.Column(db.Integer, primary_key=True) bar_id = db.Column( "bar_id", db.Integer(), db.ForeignKey("bar.id")) ...
1
vote
1answer
59 views

Populate a WTForms form object with a datetime.date

I'm cooking up a crud interface for an object representing a bill, as in the water bill, the electric bill, etc. I'm using sqlalchemy to handle the data, wtforms to handle the forms, and flask to ...
0
votes
1answer
34 views

SQLAlchemy MySQL STRAIGHT_JOIN

My code currently executes queries just fine in the SQLAlchemy ORM layer like so: session().query(model_a).join( (model_b, something == somethingelse) ).join( (model_c, something == ...
0
votes
0answers
20 views

Select name by id in another table

I have the tables Articles(id, name(text), category(int), text(text)) and Categories(id, name(text)) query db_session.query(Articles).all() How I can with ORM select All from Articles with replacing ...
0
votes
0answers
22 views

How to have more than one tables backref a table with the same property name

So I wanted to achieve, which when described in plain words, would be something like: The parent model class is able to return all the instances of models where it is ForeignKeyed, under a single ...
0
votes
1answer
16 views

SQLalchemy hierarchical hybrid-transformation

BASED on http://docs.sqlalchemy.org/ru/latest/orm/extensions/hybrid.html#hybrid-transformers Hello fellow sqlalchemy coders! I have a data of the form: from sqlalchemy import Column, Integer, ...
4
votes
1answer
27 views

SQLAlchemy : is there any good automated way to rename columns

I'm using SQLAlchemy ORM for a few days and i'm looking for a way to get tablename prefix in the results of Session.query(). For instance : myId = 4 ... data = ...
2
votes
2answers
25 views

sqlalchemy: How do I enforce date range on column?

Here is how my column looks financial_day_of_month = Column('financial_day_of_month', Integer, nullable=False, default=1) I want to enforce that min=1 and max=31 ...
0
votes
1answer
27 views

Flask-SQLAlchemy TimeoutError

My backend configuration is : Ubuntu 12.04 Python 2.7 Flask 0.9 Flask-SQLAlchemy Postgres 9.2 I've got this error message: TimeoutError: QueuePool limit of size 5 overflow 10 reached, ...
0
votes
1answer
46 views

Many-to-many relations from table to itself in SQLAlchemy

I'm using SQLAlchemy to represent a relationship between authors. I'd like to have authors related to other authors (coauthorshp), with extra data in the relation, such that with an author a I can ...
0
votes
0answers
37 views

Celery task hangs when chaining to a group

I'm trying to write a celery workflow that syncs a set of contacts from a remote system to the local database. I would like to split the results of the remote system api call into several batches, so ...
0
votes
1answer
29 views

Doing threading with sqlalchemy properly?

I have a multi threaded application where the treads work on some objects fetched using sqlalchemy. The objects are put in a thread queue which the threads poll from. In the main thread I am doing ...
1
vote
1answer
129 views

sqlalchemy.exc.ProgrammingError: (ProgrammingError) can't adapt type 'UUID'

My table is categories = table('categories', Column('uuid', UUID(), default=uuid.uuid4, primary_key=True, ...
0
votes
1answer
82 views

SQLAlchemy equivalent of named scopes in ActiveRecord

Is there an equivalent of AR's named scopes? Named scopes are basically filters, that can be wrapped in a method, and then chained. Here's an example from ...
2
votes
1answer
265 views

SQLAlchemy temporary table with Declarative Base

I need a temporary table in my programme. I have seen that this can be achieved with the "mapper" syntax in this way: t = Table( 't', metadata, Column('id', Integer, primary_key=True), # ...
2
votes
4answers
1k views

Flask SQLAlchemy query, specify column names

How do I specify the column that I want in my query using a model. (it selects all columns by default) I know how to do this with the sqlalchmey session: session.query(self.col1) but how do I do with ...
11
votes
2answers
3k views

SQL Alchemy - Getting a list of tables

I couldn't find any information about this in the documentation, but how can I get a list of tables created in SQLAlchemy? I used the class method to create the tables.
21
votes
1answer
5k views

Bulk insert with SQLAlchemy ORM

Is there any way to get SQLAlchemy to do a bulk insert rather than inserting each individual object. i.e., doing: INSERT INTO `foo` (`bar`) VALUES (1), (2), (3) rather than: INSERT INTO `foo` ...
9
votes
2answers
4k views

SQLAlchemy subquery - average of sums

is there any way how to write the following SQL statement in SQLAlchemy ORM: SELECT AVG(a1) FROM (SELECT sum(irterm.n) AS a1 FROM irterm GROUP BY irterm.item_id); Thank you
11
votes
6answers
4k views

Is there anything similar to SQLAlchemy?

I've recently started to fell in love with SQLAlchemy. You can write clean and fast SQL statements without having to write one line of SQL. There is no need to write most of the meta configuration you ...
1
vote
1answer
731 views

Is there support for the IN-operator in the “SQL Expression Language” used in SQLAlchemy?

Is it possible to express a query like the one below in the "SQL Expression Language" used in SQLAlchemy? SELECT * FROM foo WHERE foo.bar IN (1,2,3) I want to avoid writing the WHERE-clause in plain ...

1 2 3 4 5 44
15 30 50 per page