How can this be? Is this the intended behavior?
ipdb customer = factory.new_customer(_with_id=True)
ipdb with Session() as session: customer = session.merge(customer)
ipdb customer
Customer(id=10002, first_name=u'Testfirstname10002',
last_name=u'Testlastname10002',
On Wed, Nov 6, 2013 at 3:28 AM, bsa bruc...@gmail.com wrote:
After resisting ORM and database abstraction packages for a long time in
favour of plain sqlite3, I decided to give SQLAlchemy's ORM features a try.
I've managed to specify a schema and get objects in and out of tables. I'm
not sure
On Wed, Nov 6, 2013 at 11:48 AM, Victor Varvariuc
victor.varvar...@gmail.com wrote:
How can this be? Is this the intended behavior?
ipdb customer = factory.new_customer(_with_id=True)
ipdb with Session() as session: customer = session.merge(customer)
ipdb customer
Customer(id=10002,
If I merge `subscription` object into a session, `subscription.customer` is
not accessible while `subscription.customer_id` is set:
ipdb subscription.__dict__
{'domain': u'ru', 'utm_content': None, 'updated_at':
datetime.datetime(2013, 11, 6, 16, 45, 2, 85355), 'confirm_code':
Yes, you right! Thank you!
--
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to
Hi,
I want to speed up my SqlAlchemy bulk inserting code and yes, I'm aware that
this is not the main purpose of SqlAlchemy and all databases have faster low
level import tools.
The background is the following: We import data from various sources and apply
various mappings. Currently I'm
Could some please explain if its possible to access the columns in a
sub/query, so I can join on them. Here is what I am trying to do.
First lets say i start with a query like.
q = session.query(Account)
now, lets say i make another query i want to join to that.
q1 =
Hello all!
I don't know if this is something that may happen if I mixup my code too
much (or bad patterns), but I'm having the following error using 0.8.3:
*- entity_cls = self.session.query(EntityClass).filter(EntityClass.name
== struct.get('name')).first()**
**(Pdb) EntityClass**
**class
Reworking:
*- entity_cls = self.session.query(EntityClass).filter(EntityClass.name
== struct.get('name')).first()**
**(Pdb) bla = EntityClass({'name':u'blaaa'})**
* TypeError: __init__() takes exactly 1 argument (2 given)*
But my __init__ looks like this:
*def __init__(self, *args,
You can do something like:
q1 = session.query(\
ContactInfo.account_id.label(q1_account_id ),
ContactInfo.other_id.label(q1_otherid )
)\
.filter(..)
q2 = session.quiery(Site.account_id.label(q2_account_id)).filter(..)
_q3 =
sidenote: there are typos. that's just to illustrate. i mostly copied
that from production code.
the core concepts are:
1. `label()` the columns
2. use the `engine` (not orm) to join the queries
3. `alias` the union to search against them
4. the labeled columns in the earlier queries are now
In my experience, you need to write a script that you can configure
as-needed. Depending on the types of inserts, I've had different
performances.
* I always set up batches to be configurable ; I start at 100, then try
to go up down
* I set toggles/thresholds on when I `flush`. After every
Thanks guys, so i got it going with the hint to use an alias.
Here is what i ended up getting to work... BUT*** i am not using the
engine.execute does .all() work.. but its not recommended because im
not having a problem whats the issue?
Here is what im doing.
q3 = union(q1,q2).cte()
q =
Hello, everyone,
Let's say I have a class like this:
Class Foo(...):
id = Column('id', Sequence('id_seq'), primary_key=True)
color = Column(...)
size = Column(...)
How do I instantiate one of these Foo objects without specifying an id for it
(letting it come from the id_seq
i think the call to alias ( making it a subquery ) dropped the support for
all in my example; though that was written in .8.1 -- might be working
since .8.3 or 9
it took me a bit of trial and error to get stuff working.
awesome that it's working for you so quickly!
--
You received this
You missed adding the object to the session, before the flush.
this should work:
new_foo = Foo('red')
dbSession.add(new_foo)
dbSession.flush()
print new_foo.id
--
You received this message because you are subscribed to the Google Groups
sqlalchemy group.
To unsubscribe from
Jonathan,
Thank you for your time and reply, but that still does not work for me. Even
after adding the object to the session and flush()ing, its id is still None.
Thanks,
Mike
From: sqlalchemy@googlegroups.com [sqlalchemy@googlegroups.com] on behalf of
Again, stupid me. A return in a @declared_attr helps sometimes ... Sorry
to bother :)
Best regards,
Richard.
On 11/06/2013 03:21 PM, Richard Gerd Kuesters wrote:
Reworking:
*- entity_cls =
self.session.query(EntityClass).filter(EntityClass.name ==
struct.get('name')).first()**
**(Pdb)
On Nov 3, 2013, at 6:28 PM, Jon Rosebaugh chai...@gmail.com wrote:
I'm trying to implement support for Postgres's composite types, which
essentially let you make a type which is a struct of other types. This
involves several kinds of functionality:
* Psycopg2 maps composite types as
I wrote a full post regarding this topic on stackoverflow at
http://stackoverflow.com/questions/11769366/why-is-sqlalchemy-insert-with-sqlite-25-times-slower-than-using-sqlite3-directly/11769768#11769768
. If you start with this, I can answer more specific questions.
On Nov 6, 2013, at 10:28
flushing will populate the .id attribute. Set echo=True on your
create_engine() and you’ll see this happening.If you’re not seeing it, then
perhaps you’re not flushing what you think you are. Provide a fully working
sample here if all else fails, we can show you how to make it work.
All,
I got it working, and you're both right, of course, the flushing should and
ultimately does populate the .id.
In my case, I was flushing two mutually-referential objects of the same type
(rows in the same table), appending them to a relationship on an object of
another type (another
Simon,
Thanks for taking the time to read through and respond.
2) Do I need to be doing the manual flush() + get ID fiddling to create
the linkage between objects? Or is there a better way to do this, eg by
linking the objects together in code and making a single session call at
the
23 matches
Mail list logo