In SQLA 1.3.x, I used to follow this pattern to construct a query:
```
def load_something(... sort=False):
qry = select(columns=..., from_obj=...)
if sort:
qry = qry.order_by(desc(qry.c.created_on))
if ...
qry = qry...
```
but in 1.4.0 and 1.4.37 (I guess the versions in
Hi,
I'm using SQLAlchemy's Core to interface a postgres database (via psycopg2)
component alongside Flask-SQLAlchemy in a Flask app. Everything was working
fine until I recently discovered what seems to be a deadlock state which is
caused by two queries locking each other (at least that's my
Indeed, I was using version 1.0.9 and didn't realise that this wasn't an
issue with alembic. Thanks for the quick response.
On Friday, 28 June 2019 22:30:49 UTC+2, Mike Bayer wrote:
>
>
>
> On Fri, Jun 28, 2019, at 4:01 PM, gbr wrote:
>
> I've upgraded my applica
I've upgraded my application to Python 3.7 and to the latest version of
Alembic which triggers an exception when `context.get_current_revision()`
is called.
```
File "app.py", line 395, in check_database_version
current_rev = context.get_current_revision()
File
for taking the time to respond (and of course for creating
such a great library).
On Monday, 18 January 2016 18:23:04 UTC+11, gbr wrote:
>
> I've upgraded from a SQLA version 0.9.x to 1.0.9. Previously, I did the
> following when inserting new records:
>
> - Column('flag', Boolean,
resolving this without relying on buggy (and potentially not maintained)
behaviour?
Thanks for your help.
On Monday, 18 January 2016 18:23:04 UTC+11, gbr wrote:
>
> I've upgraded from a SQLA version 0.9.x to 1.0.9. Previously, I did the
> following when inserting new records:
>
> - Colu
I've upgraded from a SQLA version 0.9.x to 1.0.9. Previously, I did the
following when inserting new records:
- Column('flag', Boolean, server_default=sql.expression.false()) I didn't set
those columns locally and didn't include them in the insert statement when I
wanted them to be False
-
aults implies only a single row
> INSERT which is not the case for INSERT from SELECT.
>
>
>
>
> On 11/01/2015 01:29 AM, gbr wrote:
> > I've just tried to upgrade from 0.9.4 to the latest 1.0.9 version (yes,
> > I'm late) and am running into some problems. Most notably,
&
I've just tried to upgrade from 0.9.4 to the latest 1.0.9 version (yes, I'm
late) and am running into some problems. Most notably, `returned_defaults`
from an insert query does not seem to work as before. This is part of my
code:
new_record = select([user_id, parent_id, 1 +
Given this example, I would expect that in both cases the default value of
user.admin gets set.
from sqlalchemy import *
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker, scoped_session
engine = create_engine('sqlite:///:memory:', echo=True)
Base =
instead.
On Oct 10, 2014, at 5:12 AM, gbr doub...@directbox.com javascript:
wrote:
Given this example, I would expect that in both cases the default value of
user.admin gets set.
from sqlalchemy import *
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import
change to `server_default`...
On Saturday, 11 October 2014 09:28:32 UTC+11, gbr wrote:
I didn't know 1.0 was out already. How can I upgrade to it? `pip` and
`easy_install` still install 0.9.7...
On Saturday, 11 October 2014 08:50:05 UTC+11, Michael Bayer wrote:
I’ve implemented this feature
for the most foolproof system of putting
in default values, because the database does it. Is the “SET DEFAULT”
thing there the old or the new database?
On Oct 10, 2014, at 6:41 PM, gbr doub...@directbox.com javascript:
wrote:
The weird thing is that this problem only arose when I wanted to create
to throw out
Flask-SqlAlchemy and see how it goes, but would like to find an easier way
first). Any suggestions are appreciated.
On Friday, May 16, 2014 5:02:57 PM UTC+10, gbr wrote:
True. I should have modified
def run_migrations_online():
Run migrations in 'online' mode
in here to extract the
column reference of `k`?
a.add(column == v)
return sel.where(a)
On Wednesday, May 21, 2014 6:45:21 AM UTC+10, Michael Bayer wrote:
On May 19, 2014, at 9:12 PM, gbr doub...@directbox.com javascript:
wrote:
I'm trying to modify a select statement which
the column you want to
filter to.
-Ryan Kelly
On Mon, May 19, 2014 at 9:12 PM, gbr doub...@directbox.com javascript:
wrote:
I'm trying to modify a select statement which is fairly complex and
which is
created in a function that I don't want to modify. It is returned from
I'm trying to modify a select statement which is fairly complex and which
is created in a function that I don't want to modify. It is returned from
this function and I'd like to add more WHERE clauses by just referencing
the returned select statement. How can I do this without causing SQLA
13, 2014, at 8:41 AM, gbr doub...@directbox.com javascript:
wrote:
In some Alembic upgrade scripts, I need to use application sessions to
make use of some code that requires these sessions. To avoid deadlocks from
blocking transactions I use the following lines to transparently call
.
a workaround might be to monkeypatch select() for now:
sel = select(
[b_id, product.c.id],
).union(
select([b_id, s_id])
)
sel.select = lambda : sel
On May 8, 2014, at 6:27 PM, gbr doub...@directbox.com javascript:
wrote:
So what can I do? I'm using postgres 9.3
The error message I
I don't quite understand why SQLA generates this query. For some reason it
wraps the union part into a separate select. How can I avoid this?
b_id = 2
s_id = 3
id = product.c.id
sel = select(
[b_id, product.c.id],
).union(
select([b_id, s_id])
)
ins = insert(product).from_select([
with a raw UNION like that, we can loosen
this restriction to apply to union-orinented selects as well but it’s not
clear if some backends might have problems with it.
On May 8, 2014, at 4:28 AM, gbr doub...@directbox.com javascript:
wrote:
I don't quite understand why SQLA generates this query
can I get SQLA to create the query I want?
On Thursday, May 1, 2014 8:20:30 AM UTC+10, gbr wrote:
correlate_except(table) did the trick. I thought I had tried it before,
but something must have gone wrong. Now it works.
Thanks for your help.
On Wednesday, April 30, 2014 11:53:04 PM UTC+10
. This behaviour fairly unexpected
though. Is this somehow mentioned in the documentation? An example like
this would be great (if not already existing)...
On Tuesday, May 6, 2014 7:07:16 PM UTC+10, gbr wrote:
I'm running into a similar problem again. This time, correlate_except
doesn't change anything
For some reason, an exists() where clause which is meant to refer to an
outer element is pulling the outer element's table into the query.
What I need is as follows
SELECT anon1.id, anon1.value from (
SELECT DISTINCT ON (pp.id) pp.id AS id, pp.rev_id AS rev_id, pp.deleted
FROM prod as pp
correlate_except(table) did the trick. I thought I had tried it before, but
something must have gone wrong. Now it works.
Thanks for your help.
On Wednesday, April 30, 2014 11:53:04 PM UTC+10, Michael Bayer wrote:
On Apr 30, 2014, at 8:37 AM, gbr doub...@directbox.com javascript:
wrote
Exactly what I was looking for - thanks.
On Sunday, March 30, 2014 10:43:12 AM UTC+11, Felix Schwarz wrote:
Am 29.03.2014 23:33, schrieb gbr:
There's one thing though that I haven't been able to work out yet (maybe
this
feature doesn't exist).
How about the stamp() command?
http
@compiles in order to render. I might
have given someone that recipe at some point.
On Mar 4, 2014, at 1:39 AM, gbr doub...@directbox.com javascript:
wrote:
I know this is an old thread, but there isn't much on the web around
generate_series and SQLA, so I thought I might revive
I know this is an old thread, but there isn't much on the web around
generate_series and SQLA, so I thought I might revive it.
One of the suggestion was to use:
s = func.generate_series(4,5,6).alias(cols=['a'])
select([func.current_date() + s.c.a])
Unfortunately, alias doesn't take a `cols`
, 2013, at 11:03 PM, gbr doub...@directbox.com javascript:
wrote:
Thanks. That's quite an interesting piece of code. There's a bit of magic
happening in this code and it's not quite compatible for my use case (use
of queries instead of tables, no ORM mapping), so allow me to ask some
questions
the key in `collection` then? Or
maybe I didn't understand when the actual query is being executed...
On Thursday, September 12, 2013 11:54:20 AM UTC+10, gbr wrote:
`select_entity_from` finally did the trick. I did
qry =
session.query(child_query).select_entity_from(parent_query).join
Never mind. I think I know how this works now. I didn't realise that
`child_q` gets executed as soon as it's iterated (despite your comment).
Also, the `child.parent_id` is used as key to fill the dict...
On Thursday, September 12, 2013 2:54:47 PM UTC+10, gbr wrote:
I've still got a question
3, 2013 1:39:44 AM UTC+10, Michael Bayer wrote:
On Aug 31, 2013, at 7:33 PM, gbr doub...@directbox.com javascript:
wrote:
On Sunday, September 1, 2013 8:19:24 AM UTC+10, Michael Bayer wrote:
Let me add a bit of information. I assumed the behaviour would be the
same in ORM (actually, when
What do you mean by optimize? What's the desired goal of your
optimisation, or in other words: what's not optimal at the moment?
Looking at your table, I can think of (guess) a few things I'd do different
(namely normalisation http://en.wikipedia.org/wiki/Database_normalization).
But whether
On Sunday, September 1, 2013 8:19:24 AM UTC+10, Michael Bayer wrote:
On Aug 31, 2013, at 1:16 AM, gbr doub...@directbox.com javascript:
wrote:
Could anyone provide some suggestions on where to look in the SQLA code
(or even an example, or some general thoughts) for how to perform
Could anyone provide some suggestions on where to look in the SQLA code (or
even an example, or some general thoughts) for how to perform a
`joinedload` as the ORM does it for Core tables (or actually an already
executed query which has unresolved references which I'd like to load in a
,
but is there more documentation on this and other parts of the query?)...
Many thanks for the swift response (and SQLAlchemy for that matter :)).
On Thursday, August 29, 2013 9:46:02 PM UTC+10, Michael Bayer wrote:
On Aug 28, 2013, at 11:48 PM, gbr doub...@directbox.com javascript:
wrote
Hi,
Before spamming the issue tracker and since I'm new to SQLAlchemy and may
have misunderstood how to use `append_whereclause()`, I thought I seek
confirmation on this mailing list.
The code:
def test_append_whereclause(self):
url = 'localhost'
username = 'donald'
to compile the WHERE clause of query means we look at query.c.id
which means we must render the table query which is how it cycles.
Why does it need to compile the whole query when I just want to use than
column name of the query?
What it seems like you're looking to do is
You're right. These two queries work fine. However, I don't have access to
`location.c.id` which is why I hoped to be able to use attributes of
`query`.
I've copied the example out of a bigger program which mixes Core and ORM
features (hence the use of sessionmaker).
On Thursday, August 29,
39 matches
Mail list logo