[sqlalchemy] Explicitly name the not null constraint for an Oracle primary key

2015-12-04 Thread Thijs Engels
Dear all, For maintenance purposes I have aiming to ensure that ALL database constraint have an explicit name (as recommended here as well: http://alembic.readthedocs.org/en/latest/naming.html) With the NOT NULL constraints this can be done by adding an explicit CheckConstraint. However at least

[sqlalchemy] Using bindparams in a lazily loaded relationship

2015-12-04 Thread Daniel Thul
I configured a relationship to use a bindparam as part of its primaryjoin condition. This works as long as the relationship is loaded eagerly. As soon as I switch to lazy loading it won't resolve the relationship properly. I guess this is because the lazy load "forgets" the params that have been

RE: [sqlalchemy] Explicitly name the not null constraint for an Oracle primary key

2015-12-04 Thread Gombas, Gabor
Hi, We solved this a long time ago using an extra function, which gets called after SQLAlchemy did its part. The function queries all constraints, and renames the ones which look like NOT NULL constraints having a name starting with SYS_. This method works well in practice, and since we have

[sqlalchemy] Re: inserts rows in wrong order

2015-12-04 Thread Nana Okyere
Jonathan, Thanks but output_batch is a* list* of dictionaries. So ultimately, it is a list. Its elements are the dictionaries containing the key - value pairs i.e. column name : column value . Therefore the order of the *list* should be preserved. -- You received this message because you are

[sqlalchemy] Re: inserts rows in wrong order

2015-12-04 Thread Jonathan Vanasco
Sorry, hadn't finished my morning coffee and this "registered" as a dict ordering. Without seeing code, it's hard to understand what is going on. Here's my guess: * When you call the insert(), the `output_batch` is inserted into the DB in that order. This is expected and you should see that

[sqlalchemy] Re: inserts rows in wrong order

2015-12-04 Thread Jonathan Vanasco
Python dictionars do not preserve the order. You could try using an OrderedDict https://docs.python.org/2/library/collections.html -- 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,

Re: [sqlalchemy] Explicitly name the not null constraint for an Oracle primary key

2015-12-04 Thread Mike Bayer
On 12/04/2015 07:25 AM, Thijs Engels wrote: > Dear all, > > For maintenance purposes I have aiming to ensure that ALL database > constraint have an explicit name (as recommended here as well: > http://alembic.readthedocs.org/en/latest/naming.html) > > With the NOT NULL constraints this can be

Re: [sqlalchemy] Re: inserts rows in wrong order

2015-12-04 Thread Nana Okyere
Thanks guys. I'll add an id column and order by it. -- 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

Re: [sqlalchemy] Using bindparams in a lazily loaded relationship

2015-12-04 Thread Mike Bayer
On 12/04/2015 10:18 AM, Daniel Thul wrote: > I configured a relationship to use a bindparam as part of its > primaryjoin condition. > This works as long as the relationship is loaded eagerly. As soon as I > switch to lazy loading it won't resolve the relationship properly. > I guess this is

Re: [sqlalchemy] Re: inserts rows in wrong order

2015-12-04 Thread Mike Bayer
On 12/04/2015 01:55 PM, Nana Okyere wrote: > Much thanks. > I think you may have hinted on something about the order in which the > database returns rows. I thought that it always returns the rows in the > order they were inserted. From what you're saying, that's a wrong > assumption. So to

Re: [sqlalchemy] Re: inserts rows in wrong order

2015-12-04 Thread Jonathan Vanasco
Yeah, you need an "id" field to do that and "ORDER BY" it. It's a benefit/limitation of SQL -- save time by giving random rows, or spend time sorting them. Something that you should be wary of though... If you do this: INSERT INTO table (id) values (1,2,3,4...10); Your select would be:

[sqlalchemy] Re: inserts rows in wrong order

2015-12-04 Thread Nana Okyere
Much thanks. I think you may have hinted on something about the order in which the database returns rows. I thought that it always returns the rows in the order they were inserted. From what you're saying, that's a wrong assumption. So to give you a little more info, the data being written to