Re: [sqlalchemy] Specifying a Row Check Constraint and Compound Primary Keys

2014-07-29 Thread Werner
Hi Rich, I don't like using 'name' columns as primary keys I would instead use an 'id' column and would set 'index=True' on the name column. On the primary key also define a Sequence: Column('id', Integer, Sequence('tablename_id_seq'), primary_key=True) http://sqlalchemy.readthedocs.org/en/r

[sqlalchemy] Problem going from 0.7.10 to 0.8.7

2014-07-29 Thread Mike Bernson
I have started moving my code base from 0.7.10 to 0.8.7 as first step to getting to current version. (There code changes for me to get to 0.9.x where there are no code changes to run under 0.8.x) I have found a problem with a query that worked on 0.7.10 and now fails with a raise. The code is fa

Re: [sqlalchemy] Specifying a Row Check Constraint and Compound Primary Keys

2014-07-29 Thread Rich Shepard
On Tue, 29 Jul 2014, Rich Shepard wrote: CheckConstraint(org_lvl("org_lvl IN ('Federal', 'State', 'County', 'City', 'Local', 'Regional')") Oops! that first 'org_lvl(' comes out. Rich -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To

Re: [sqlalchemy] Specifying a Row Check Constraint and Compound Primary Keys

2014-07-29 Thread Rich Shepard
On Tue, 29 Jul 2014, Simon King wrote: Hope that helps, Simon, and others: As a check that I understand the basics please check the syntax of this set of three related tables: class Agencies(Base): __tablename__ = 'agencies' org_name = Column(String(48), primary_key = True) ac

Re: [sqlalchemy] Specifying a Row Check Constraint and Compound Primary Keys [RESOLVED]

2014-07-29 Thread Rich Shepard
On Tue, 29 Jul 2014, Simon King wrote: Sorry, I don't know the answer to this, but based on the "attrib" example, I would guess that the string is passed directly to the database, so you would write something like: agency_name.CheckConstraint("agency_name IN ('Federal', 'State', 'County', 'City

Re: [sqlalchemy] Specifying a Row Check Constraint and Compound Primary Keys

2014-07-29 Thread Simon King
On Tue, Jul 29, 2014 at 2:40 PM, Rich Shepard wrote: > I'm starting to learn SQLAlchemy; have 0.9.7 installed on Slackware-14.1 > with Python-2.7.5, wxPython-3.0.0.0, and postgresql-9.3.4. > > 1) In the docs I see a row constraint example using an integer comparison > attrib.CheckConstraint('

[sqlalchemy] Specifying a Row Check Constraint and Compound Primary Keys

2014-07-29 Thread Rich Shepard
I'm starting to learn SQLAlchemy; have 0.9.7 installed on Slackware-14.1 with Python-2.7.5, wxPython-3.0.0.0, and postgresql-9.3.4. 1) In the docs I see a row constraint example using an integer comparison attrib.CheckConstraint('attrib>5'). What is the syntax for a list, such as this postgr

Re: [sqlalchemy] handling Integrity error gracefully

2014-07-29 Thread Jonathan Vanasco
If you're doing a huge SELECT or batched INSERT/UPDATEs, the operation may be more efficient -- but the transactions will be longer, which means you will create issues with other connections. unless you grab exclusive locks on tables, you also run a higher risk of integrity errors. In my exper

Re: [sqlalchemy] Re: Generating models from data

2014-07-29 Thread Mauricio de Abreu Antunes
Excellent job :-) Actually I already know it because I follow you @Github. 2014-07-29 11:53 GMT-03:00 Jonathan Vanasco : > If I read the docs and examples correctly... you give it sample data as > Python/Json/YAML, and this package turns it into the appropriate models? > > That's pretty brillian

[sqlalchemy] Re: Generating models from data

2014-07-29 Thread Jonathan Vanasco
If I read the docs and examples correctly... you give it sample data as Python/Json/YAML, and this package turns it into the appropriate models? That's pretty brilliant for rapid prototyping use! -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. T

Re: [sqlalchemy] handling Integrity error gracefully

2014-07-29 Thread Michael Bayer
you can load just primary key attributes, sure, or you can load batches of objects in that correspond to the field of identifiers you're working with. Sort the input in PK order so that you only need to fetch a chunk at a time. Mapped objects can be hashed normally too, though the default hash

Re: [sqlalchemy] handling Integrity error gracefully

2014-07-29 Thread Milind Vaidya
With reference to you comment above "personally I prefer just to emit a SELECT first, which may be a per-row SELECT or may be a prefetch of all the rows from the table in question." This approach is faster as it allows me to create a bunch of objects that are new and use add_all() to push them

[sqlalchemy] How to reveal a certain relationship's cascade mode at runtime?

2014-07-29 Thread Bao Niu
I am using automap. I am not sure about the configuration of certain relationships' cascade. Is there a way to find it out at runtime? class User(sql_base): __tablename__ = "user" class Address(sql_base): __tablename__ = "address" sql_base.prepare(sa_engine, reflect=True) -- You rece

Re: [sqlalchemy] How can I use the transaction to make sure data is one by on?

2014-07-29 Thread Jonathan Rogers
On 07/29/2014 02:50 AM, 'Frank Liou' via sqlalchemy wrote: > My question is I want to add some data > > But what if so many people add in the same time? Is it will error? > > So > > Can i that the add code limit in one guy to use when he is add over then > release limit code and let other guy t