On Fri, Aug 3, 2018 at 3:29 PM, Derek Lambert wrote:
> When deleting a child object in a one-to-many relationship retrieved with
> the raiseload('*') query option an exception is raised. Adding
> passive_deletes=True to the relationship on the child prevents the
> exception, but that seems like a
When deleting a child object in a one-to-many relationship retrieved with
the raiseload('*') query option an exception is raised. Adding
passive_deletes=True to the relationship on the child prevents the
exception, but that seems like a hack.
I can remove the option from the query, but I'm
I sorted this problem out and, as you predicted, it turned out to be layers
upon layers of problems. If
you do not mind having a quick look at how I resolved this, I would really
appreciate some feedback
and a second opinion...
I actually missed the main problem initially. It had to do with the
It is a list of dictionaries indeed.
I will investigate this issue tomorrow. If something useful comes out or if
I have any more questions, I will write back here.
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please
On Wed, Jan 3, 2018 at 12:30 PM, Jevgenij Kusakovskij wrote:
> Thank you for such a quick response!
>
> Tried your suggestions, but still getting the same error.
>
> And could it be caused by some data in the DataFrame being 'odd'? E.g.
> Timestamp('2012-05-22 00:00:00')
Thank you for such a quick response!
Tried your suggestions, but still getting the same error.
And could it be caused by some data in the DataFrame being 'odd'? E.g.
Timestamp('2012-05-22 00:00:00') assigned to col2.
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
On Wed, Jan 3, 2018 at 11:21 AM, Jevgenij Kusakovskij wrote:
> I feel bad bugging you with questions everyday, but it seems that I get them
> answered here... Hope I am not abusing your hospitality.
>
> I would like to delete multiple rows from a table on a MS SQL Server. The
>
I feel bad bugging you with questions everyday, but it seems that I get
them answered here... Hope I am not abusing your hospitality.
I would like to delete multiple rows from a table on a MS SQL Server. The
rows to be deleted are given in a `pandas.DataFrame` object and there can
be thousands
Calling session.delete() is equivalent to calling session.add() first.
The only downside is if the object represents state that has changed in the
database elsewhere, like the row was already deleted or had a primary key
change.
On Dec 28, 2016 8:18 AM, "Julio César Gázquez" <
Hi list.
I just noticed that if I retrieve an object, and close the session
letting the object in detached state, then I can delete the object from
the database using a new session simply issuing session.delete(),
without merging it first. SQL Alchemy simply emits the DELETE and that's
it,
I have some buried-in-the-codebase-since-0.7 upsert code that uses `merge`.
In order to avoid certain attributes from being used in the merge
comparison, the attributes were deleted using delattr..
The code looks something like this:
db_obj = sess.query(obj_type).filter_by(**filters).one()
pk
On 4/5/15 12:32 AM, Russ wrote:
I have some buried-in-the-codebase-since-0.7 upsert code that uses
`merge`. In order to avoid certain attributes from being used in the
merge comparison, the attributes were deleted using delattr..
The code looks something like this:
db_obj =
I have a many-to-many relationship in my models. This is what they look
like:
class Post(db.Model):
__tablename__ = 'Posts'
id = db.Column(db.Integer, primary_key=True)
tags_relationship = db.relationship('Tag', secondary=tags, backref=db.
backref('posts', lazy='dynamic'))
tags =
I've spent time unsuccessfully trying to fix some problems with a
many-to-many table
and lazy joins.
Here's a simplified repro:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import random
from sqlalchemy import create_engine, ForeignKey
from sqlalchemy import Column,
Thanks! I went with
Appointment.persons = relationship(
'AppointmentPerson',
cascade='delete-orphan, delete, save-update, merge, expunge',
lazy=LAZYJOIN)
and used the slice notation to empty the InstrumentedList:
appt.persons[:] = []
In my real app, I spent
(Apologies if this is a dupe. I posted it twice via the GG webpage and it
never showed up.)
I've spent time unsuccessfully trying to fix some problems
with a many-to-many relationship and lazy joins.
Here's a simplified repro:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import
On May 19, 2014, at 12:07 PM, George Reilly george.v.rei...@gmail.com wrote:
The code originally used
Appointment.persons = relationship(
'AppointmentPerson',
cascade='delete, save-update, merge, expunge',
lazy='dynamic')
where everything worked, but
I have a m2m relationship of Posts and Categories. A post can be in any
number of categories, and a category can have any number of posts. This
relation is defined on the Post model:
categories = relation(Category, lazy=True, secondary=PostCategory.__table__,
this question is arising with unusual frequency in recent weeks, which suggests
a shortcoming in the docs. Rather than answering here, I've added what is
hopefully a comprehensive answer to the documentation; it would be helpful if
you could confirm for me that it answers your question, or if
The documentation is fine, I just get lost in it sometimes because there is
so much, and I have a hard time tracking down the specific thing I'm
looking for.
It turns out I was just overcomplicating things. Once I removed 'cascade'
from the ref, everything works as expected. Had I just left
well dont worry, that doc is new as of an hour ago, and I dont think that
behavior is actually explained anywhere; historically, people tend to not worry
about it and it just happens, though there have been stackoverflow questions
about it lately. it's better that it's described.
On Jun 25,
Hi all,
I looking for a way to delete/empty a sqlite database completely (can
be in memory or file). I have tried:
- metadata.drop_all(engine); which does not work with cyclic
references
- solution from http://www.sqlalchemy.org/trac/wiki/UsageRecipes/DropEverything;
it requires names of
Hello,
I am unsure on how to delete correctly. Lets say I have a query's result,
which is a list. del list[5] does not seem to do anything, right? I would
always have to do session.delete(list[5])?
But what about when I created a mapped object, which is not yet
persistent, how would I
2010/4/14 Sebastian Elsner sebast...@risefx.com:
I am unsure on how to delete correctly. Lets say I have a query's result,
which is a list. del list[5] does not seem to do anything, right? I would
always have to do session.delete(list[5])?
Correct. del list[5] only delete the instance in
Hello,
I have several objects from a relation that I'd like to delete. To me,
this would be a natural syntax:
session.delete(office.users)
to delete all of the user objects. I get this error when doing this:
raise exc.UnmappedInstanceError(instance)
Hello,
I've got many to many relation: Reservation to Host. In Reservation I've
got collection (apparently an instance of InstrumentedList) of hosts.
How can I delete element from that collection? That is, I do not need to
delete Host per se, just delete reference to it in Reservation.hosts.
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 after_delete
function, and that function checks to see if the
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 ?
not it look like this :
stuff =
This seems like it would be a very common scenario, but it's got me
stumped and feeling a bit stupid at the moment - I would appreciate
anyone helping to point me in the right direction.
I'm using the ORM for a many-to-many relationship, for which over time
I need to be able to prune individual
Hi All,
at the end, I finally cracked the problem with the tree-structured
database with SQLAlchemy. I still have however a problem.
I am using a physical database, not an in-memory one. I have
declared my Tables as follows:
trees = Table('treenodes', metadata,
Hello,
I'm using SQLAlchemy 0.3.4. I'm having the following problem when trying
to delete an object:
client = model.Client.get(1)
client
mp.models.clients.Client object at 0x1088210
client.delete()
Traceback (most recent call last):
File console, line 1, in ?
File
31 matches
Mail list logo