[sqlalchemy] returning a dynamic query from Column.default callable

2016-03-19 Thread Jonathan Beluch
Background: Using core we have tables defined in a few separate files. Goal: To have column defaults be selectables which reference other tables while avoiding circular imports. To avoid circular imports I cannot always build the selects at import time, they have to be generated inside a

[sqlalchemy] Re: how can I search rows containing jsonb data on the basis of it's key>

2016-03-19 Thread Jonathan Beluch
> > so my sudo code for where is where dramt.key = '1'. > .where(or_(table.c.dramt.has_key('1'), table.c.cramt.has_key('1'))) This only works for JSONB. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop

Re: [sqlalchemy] returning a dynamic query from Column.default callable

2016-03-19 Thread Jonathan Beluch
er.process(select([table_b]).as_scalar()) > > m = MetaData() > > > table_a = Table( > 'a', m, > Column('id', Integer), > Column('data', Integer, default=MyThing()) > ) > > table_b = Table( > 'b', m, > Column('id', Intege

Re: [sqlalchemy] returning a dynamic query from Column.default callable

2016-03-19 Thread Jonathan Beluch
We're just using core, is there some equivalent? On Thursday, March 17, 2016 at 3:19:23 PM UTC-6, Mike Bayer wrote: > > > > On 03/17/2016 04:47 PM, Jonathan Beluch wrote: > > Background: Using core we have tables defined in a few separate files. > > Goal: To have column

Re: [sqlalchemy] Asymmetry between engine.begin() and connection.begin()

2016-02-24 Thread Jonathan Beluch
already a > Connection, is "branched", meaning it is safe to call close() on it > without affecting the original. > > So fully: > > with engine_or_connection.connect() as conn: > with conn.begin() as trans: > # etc. > > > On 02/23/2016 1

[sqlalchemy] Re: Asymmetry between engine.begin() and connection.begin()

2016-02-23 Thread Jonathan Beluch
Actually my example isn't fully correct for the case of passing in a connection not in a transaction but the question remains. On Tuesday, February 23, 2016 at 9:05:03 PM UTC-7, Jonathan Beluch wrote: > > Is there a better way of doing this? Basically I have a function that &

[sqlalchemy] Asymmetry between engine.begin() and connection.begin()

2016-02-23 Thread Jonathan Beluch
Is there a better way of doing this? Basically I have a function that takes a connectable (engine or connection) and I want to start a transaction. However I can't just call .begin() because it could return a Transaction or a Connection depending on what was passed in and I need a connection.

[sqlalchemy] Thoughts on Column(unique=True, index=True) creating a unique constraint for postgres?

2016-02-09 Thread Jonathan Beluch
Not sure about other DBs, but according to pg docs [1], it's preferred to make a unique constraint (and know that you get the index for free) versus creating a unique index. Knowing this for pg, you can just do unique=True and get the constraint and the index. I realize this is a very small

issue with --autogenerate and shortened identifiers

2015-12-27 Thread Jonathan Beluch
I'm having a problem with indexes whose name is longer than max_identifier_length and the comparisons during --autogenerate. The index on the code/metadata side is being compared using its auto-generated naming convention name, which doesn't take into account the max_identifier_length since

Re: autogenerate always generates CREATE TABLE for existing views when they are defined in code

2015-12-26 Thread Jonathan Beluch
> > In the meantime, the standard way to control what autogenerate considers > is using the include_object callable: > > > http://alembic.readthedocs.org/en/latest/api/runtime.html#alembic.runtime.environment.EnvironmentContext.configure.params.include_object > > > here, you can even call the

[sqlalchemy] insert.from_select and include_defaults=True causing bindparam name conflict

2015-12-09 Thread Jonathan Beluch
Hi, using sqlalchemy 1.0.9 and python 2.7.10. import sqlalchemy as sa meta = sa.MetaData() table = sa.Table('mytable', meta, sa.Column('foo', sa.String), sa.Column('bar', sa.String, default='baz'), ) select = sa.select([table.c.foo]) insert = table.insert().from_select(['foo'], select,