Doh that's exactly what I need. Need to read through the docs again, I
missed that parameter.
Thanks!
On Monday, August 6, 2018 at 4:46:57 PM UTC-5, Mike Bayer wrote:
>
> On Mon, Aug 6, 2018 at 4:14 PM, Derek Lambert > wrote:
> > I do want it to tell me when stuff is being eager loaded so I
On Mon, Aug 6, 2018 at 4:14 PM, Derek Lambert wrote:
> I do want it to tell me when stuff is being eager loaded so I can optimize
> those queries.
>
> SQLAlchemy shouldn't need to know about the other end of the relationship to
> delete the person should it?
>
> I didn't notice this before, but
I do want it to tell me when stuff is being eager loaded so I can optimize
those queries.
SQLAlchemy shouldn't need to know about the other end of the relationship
to delete the person should it?
I didn't notice this before, but when I add passive_deletes=True on the
"many" side I get the
I haven't looked at your code in detail, so this may not be the cause
of the problem, but in general it is a bad idea to modify a collection
while you are iterating over it. ie. this is not generally safe:
for tag in edit_post.tags:
edit_post.tags.remove(tag)
Removing the tag from the tags
Hi Simon,
I followed your advice, and changed my code to this:
def edit(id, tags=None):
edit_post = Post.query.get(id)
if tags is not None and tags != :
for tag in tags.split(','):
tag = tag.strip( )
if tag not in edit_post.tags:
add_tags =
I looked at my code some more, and found a now obvious mistake. I changed
my code to:
def edit(id, tags=None):
edit_post = Post.query.get(id)
if tags is not None and tags != :
for tag in tags.split(','):
tag = tag.strip( )
if tag not in edit_post.tags:
Thank you for the extensive reply. It makes things a lot clearer;
still i am not sure about how to continue.
Conceptually i would like to create 2 sets of tables/classes in a
database (as part of a prototype):
1) one set of tables/classes with the parameters to generate other
classes/tables
On Feb 27, 2012, at 9:55 AM, lars van gemerden wrote:
Thank you for the extensive reply. It makes things a lot clearer;
still i am not sure about how to continue.
Conceptually i would like to create 2 sets of tables/classes in a
database (as part of a prototype):
1) one set of
The only database link between these two sets is the 'polymorphic on'
column in the root base table in set 2, which is a foreign key to a
Type table in set 1.
also, I'd set up this foreign key using a literal Column so you don't have to
worry about string lookups:
On 19 Aug 2009, at 18:32, Mike Conley wrote:
The delete method of query supports bulk deletes.
In your case it might be something like
session.query(Users).filter(User.officeid==office.id).delete()
Any query can be used; there are probably more elegant ways to take
advantage of the
On Aug 20, 2009, at 12:30 PM, thatsanicehatyouh...@mac.com wrote:
On 19 Aug 2009, at 18:32, Mike Conley wrote:
The delete method of query supports bulk deletes.
In your case it might be something like
session.query(Users).filter(User.officeid==office.id).delete()
Any query can be
The delete method of query supports bulk deletes.
In your case it might be something like
session.query(Users).filter(User.officeid==office.id).delete()
Any query can be used; there are probably more elegant ways to take
advantage of the relation 'users' also.
Make sure you read the
and what that shoud do? attached is a changed version... do see if
that's what u want (it's sqlite, with plain session).
the only real change is cascade=all,delete-orphan on house.owners...
but i just unintentionaly guessed it.
On Thursday 27 November 2008 09:51:38 David Harrison wrote:
So
Postgres is the intended deployment platform so it really does need to
work on Postgres, that said last time I dug into this I found that
SQLite is less strict on enforcing key constraints where Postgres
isn't, so technically Postgres is right to complain.
2008/11/27 [EMAIL PROTECTED]:
and
so my version does work on postgres too (did u try it?)..
at least finishes with no errors.
or should there be other checks? like what's left in each table?
On Thursday 27 November 2008 10:30:04 David Harrison wrote:
Postgres is the intended deployment platform so it really does need
to work
You've changed the session object though, this is for a web app so the
scoped session is what I need. That then immediately breaks all the
session.save calls.
2008/11/27 [EMAIL PROTECTED]:
so my version does work on postgres too (did u try it?)..
at least finishes with no errors.
or should
i've modified all relations to be all,delete-orphan and now it does
add them all - as your scoped session does - and then complains:
Deleting owner
BEGIN
DELETE FROM friendship WHERE friendship.id = %(id)s
[{'id': 1L}, {'id': 2L}]
DELETE FROM owner WHERE owner.id = %(id)s
{'id': 1L}
DELETE
Which was the error I posted to ask about in the first place ;-)
Writing a session extension for this problem seems like using a very
very very large hammer, since I only need to trigger my 'manual
cascade' in a particular circumstance.
I'm hoping Mike or one of the devs might have advice on
On Thursday 27 November 2008 11:42:28 David Harrison wrote:
Which was the error I posted to ask about in the first place ;-)
Writing a session extension for this problem seems like using a
very very very large hammer, since I only need to trigger my
'manual cascade' in a particular
On Nov 27, 2008, at 1:15 AM, David Harrison wrote:
Hey all,
I've got a situation where I have 2 object A and B, and a third object
C that has a foreign key reference to both A and B. I can have many
C's that map to the same A.
Now I've implemented a MapperExtension for C that has an
i'm not expert on these, but i think u need something like
cascade='all' on your relation, _instead_ of the mapperExt. check the
docs about possible settings. the mapperExt fires too late and the
session flush-plan gets surprised.
On Thursday 27 November 2008 08:15:04 David Harrison wrote:
Sorry, I should probably have mentioned that C isn't the only object
that maps A, so a cascade doesn't work.
2008/11/27 [EMAIL PROTECTED]:
i'm not expert on these, but i think u need something like
cascade='all' on your relation, _instead_ of the mapperExt. check the
docs about possible
So this is actually a follow on from a question I posed quite a while back now:
http://groups.google.com/group/sqlalchemy/browse_thread/thread/4530dd3f5585/eb4638599b02577d?lnk=gstq=Postgres+cascade+error#eb4638599b02577d
So my approach to solving this problem was to use a MapperExtension,
On Nov 22, 2007, at 1:45 AM, imgrey wrote:
Good Day sqlalchemy.
I was searching, but didn't found a way to delete records from db not
executing selection first.
So, how to represent this SQL statement in slqalchemy ORM :
DELETE FROM a WHERE b = c ?
just execute the SQL directly,
You must istantiate an istance of the obj to be deleted.
This is an Object Manager, so all operation is available on object.
or you can execute a plain string-sql direclty from engine
connection = engine.connect()
connection.execute(DELETE FROM a WHERE b = c)
or I can do this :
imgrey ha scritto:
Good Day sqlalchemy.
I was searching, but didn't found a way to delete records from db not
executing selection first.
You must istantiate an istance of the obj to be deleted.
This is an Object Manager, so all operation is available on object.
or you can execute a
what version u use?
i tried your thing, that is
$ python -i zz.py
s = create_session()
j = s.query(Job)[0] #get first
del j.files[0]
s.flush()
and seems to work
before:
for a in s.query(Job): print a.name, a.files
...
Job 1 [__main__.File object at 0xb78ec72c, __main__.File object at
On Jun 13, 2007, at 7:45 AM, [EMAIL PROTECTED] wrote:
the only line removed was the from .orm import * - u shouldnt
use any of those internal stuff unless u know what u do.
no, this will be required in 0.4, and its mentioned in some of the
0.3 docs as well. sqlalchemy.orm is not an
On Jun 13, 2007, at 6:13 AM, David Bolen wrote:
* I want to remove the association between File Common and Job 1
but without affecting Job 2.
If I session.delete() the fc instance directly, SA purges the file
completely, including links to both jobs. I can understand SA
thinking
Michael Bayer [EMAIL PROTECTED] writes:
On Jun 13, 2007, at 6:13 AM, David Bolen wrote:
* I want to remove the association between File Common and Job 1
but without affecting Job 2.
If I session.delete() the fc instance directly, SA purges the file
completely, including links to
On the second point, the complexity of the full cascade recursion
with orphan detection makes sense. I suppose I'm interested in any
input from anyone else as to how they are handling these sorts of
operations in many-to-many cases with changing associations.
As i need a history
This is the db-file size, which is actual DB-implemenation detail, and
which will probably only grow up - depends on the particular db u
have. There are many strategies, like paging etc. e.g. some DBs
require a whole partition just for themselves - dont even think of
shrinking those...
See
Hi Svilen,
first of all, thank you for your answer.
On 3/8/07, svilen wrote:
This is the db-file size, which is actual DB-implemenation detail, and
which will probably only grow up - depends on the particular db u
have. There are many strategies, like paging etc. e.g. some DBs
require
On Mar 8, 2007, at 10:08 AM, Andrea Gavana wrote:
By printing the node names, I know that bad_node is no more there, but
its data seems to still live in the database. I mean, even if I delete
*all* the items, the database size is still 180 Kb, no matter how much
I flush(), clear(), close()
Hi Michael,
On 3/8/07, Michael Bayer wrote:
have you verified that the tables have been deleted from ? if the
filesize doesnt shrink, that may be an artifact of sqlite's
implementation.
Thank you for your answer. Well, I can reproduce it in a small Python
script that I attach to my email. At
setting the newDataBase flag to False, heres the echo at the end:
2007-03-08 14:30:26,428 INFO sqlalchemy.engine.base.Engine.0x..50 BEGIN
2007-03-08 14:30:26,435 INFO sqlalchemy.engine.base.Engine.0x..50
DELETE FROM treenodes WHERE treenodes.node_id = ?
2007-03-08 14:30:26,441 INFO
Hi Michael and All,
thank you for your detailed answer, and to have tried the demo I
have attached. I understand what you meant and you are perfectly
right, but if I can bother you with another small question:
On 3/8/07, Michael Bayer wrote:
z-eeks-Computer:~/dev/sqlalchemy classic$
On Mar 8, 2007, at 5:14 PM, Andrea Gavana wrote:
so, its all deleted. filesize is irrelevant.
Uhm, really? What happens if Windows is saying that the filesize is 4
GB of empty things? I told you I know next to nothing about database,
but it seems a bit odd to me that the file size
Hi Michael,
On 3/8/07, Michael Bayer wrote:
but the point is, and why its irrelvant to me as the maintainer of
SQLAlchemy, is that this is totally an issue with sqlite, and has
nothing to do with SQLAlchemy. you should ask on their mailing list
about this particular behavior.
Sorry, I
Hi Michael and All,
On 3/8/07, Michael Bayer wrote:
but the point is, and why its irrelvant to me as the maintainer of
SQLAlchemy, is that this is totally an issue with sqlite, and has
nothing to do with SQLAlchemy. you should ask on their mailing list
about this particular behavior.
40 matches
Mail list logo