[sqlalchemy] [alembic] equivalent to `makemigrations --check`

2024-03-11 Thread Chris Withers
the model that are not reflected in migrations. I guess this boils down to "is the current db state plus any outstanding migrations equal to the model in this checkout"... cheers, Chris -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example

Re: [sqlalchemy] Re: testing patterns with sqlalchemy 2.0

2022-09-02 Thread Chris Withers
ity to work on a small section and do efficient test runs during development. Creating a database for every unit test feels like something that would be slow enough to be annoying. How are you creating databases such that it's fast enough for this not to be the case? Chris -- SQLAlch

[sqlalchemy] testing patterns with sqlalchemy 2.0

2022-08-31 Thread Chris Withers
create_all? Something else? cheers, Chris -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description

[sqlalchemy] SQLAlchemy 1.3.23 turn off before_compile with **kwargs?

2021-03-01 Thread Chris Simpson
wargs["include_archived"] is not True and desc["type"] is Person: entity = desc["entity"] query = query.filter(entity.archived == 0) return query Kind regards Chris -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapp

Re: [sqlalchemy] Re: SQLAlchemy join/has query with example code

2021-02-09 Thread Chris Simpson
Thanks Mike, the assurance it's the right idea was what I wanted to check. All sorted much appreciated. On Sun, 7 Feb 2021, 21:49 Mike Bayer, wrote: > > > On Sat, Feb 6, 2021, at 8:56 AM, Chris Simpson wrote: > > After posting, I have arrived at *a* solution (which might be awfu

[sqlalchemy] Re: SQLAlchemy join/has query with example code

2021-02-06 Thread Chris Simpson
==PlanRequirements.plan_id)\ .filter(PlanRequirements.subscription==1).all() Kind regards, Chris On Saturday, 6 February 2021 at 13:42:54 UTC Chris Simpson wrote: > Hello, > > I'm trying to convert this working SQL query: (SQLAlchemy models are below) > > SELECT COUNT(*) >

[sqlalchemy] SQLAlchemy join/has query with example code

2021-02-06 Thread Chris Simpson
Hello, I'm trying to convert this working SQL query: (SQLAlchemy models are below) SELECT COUNT(*) FROM person JOIN subscription ON person.id = subscription.person_id JOIN plan ON subscription.sku_uuid = plan.uuid JOIN plan_requirements ON plan.id = plan_requirements.plan_id WHERE

[sqlalchemy] FetchedValue columns are INSERTed by Session.merge()

2020-10-02 Thread Wilson, Chris
INSERT INTO dog (id, xmin, name) VALUES (%(id)s, %(xmin)s, %(name)s)] [parameters: {'id': 1, 'xmin': '283302364', 'name': 'fido'}] (Background on this error at: http://sqlalche.me/e/f405) Note that this is raised when fido_2 is inserted (after fido_1 is merged into a new session). Thanks, Chris

[sqlalchemy] Interval vs DATETIME in ORM Internals

2019-12-30 Thread Chris Modzelewski
the best, Chris Sent from my iPhone -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You

[sqlalchemy] refresh_flush instance event not called for PK attributes

2019-12-19 Thread Chris Wilson
rs}") with session.begin() as trans: session.add(Dog(name="fido")) Thanks, Chris. This email is confidential. If you are not the intended recipient, please advise us immediately and delete this message. The registered name of Cantab- part of GAM Systematic is Cantab Capital

Re: [sqlalchemy] Oracle wallets + proxy authentication with arguments encoded as strings in URL

2019-11-14 Thread Chris Stephens
"oracle://[proxy_to_user]@my_wallet" worked! Thanks again. On Thu, Nov 14, 2019 at 2:14 PM Mike Bayer wrote: > > > On Thu, Nov 14, 2019, at 2:52 PM, Chris Stephens wrote: > > I'm attempting to make use of an Oracle wallet with proxy authentication &

[sqlalchemy] Oracle wallets + proxy authentication with arguments encoded as strings in URL

2019-11-14 Thread Chris Stephens
I'm attempting to make use of an Oracle wallet with proxy authentication passed as strings in URL. The documentation states: "Changed in version 1.3: the cx_oracle dialect now accepts all argument names within the URL string itself, to be passed to the cx_Oracle DBAPI. As was the case earlier

Re: [sqlalchemy] Masking SAWarning: Flushing object ... with incompatible polymorphic identity

2019-06-21 Thread Chris Withers
On 20/06/2019 16:00, Mike Bayer wrote: On Thu, Jun 20, 2019, at 3:14 AM, Chris Withers wrote: Hi All, I'm getting this warning: SAWarning: Flushing object with incompatible polymorphic identity ; the object may not refresh and/or load correctly (this warning may be suppressed after 10

Re: [sqlalchemy] Masking SAWarning: Flushing object ... with incompatible polymorphic identity

2019-06-21 Thread Chris Withers
ible polymorphic identity %r; the "     "object may not refresh and/or load correctly",     (object(), 'foo'), ) with the filter I get no output Yay! :-) I hate warn filtering, it never seems to work right for me, sorry, this is probably a rabbit hole that's not worth

Re: [sqlalchemy] Re: Masking SAWarning: Flushing object ... with incompatible polymorphic identity

2019-06-21 Thread Chris Withers
On 20/06/2019 18:50, Jonathan Vanasco wrote: On Thursday, June 20, 2019 at 3:14:06 AM UTC-4, Chris Withers wrote: How can I indicate in my code that this is intentional and no warning should be omitted? Personal option: I would not mask these.  I would let them persist

Re: merging old versions

2019-06-21 Thread Chris Withers
>> On Thu, Jun 20, 2019 at 2:37 AM Chris Withers > <mailto:ch...@withers.org>> wrote: >> >> Hi All, >> >> I have some versions that make use of the third party package I no >> longer use, how do I collapse down alembic revisions that hav

merging old versions

2019-06-20 Thread Chris Withers
but that doesn't feel right... Chris -- You received this message because you are subscribed to the Google Groups "sqlalchemy-alembic" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy-alembic+unsubscr...@googlegroups.com. To view this discussion

[sqlalchemy] Masking SAWarning: Flushing object ... with incompatible polymorphic identity

2019-06-20 Thread Chris Withers
they're coming from a third party library that's awaiting a fix), but the SAWarning doesn't catch the above. cheers, Chris -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verif

Re: [sqlalchemy] testing that a session is committed correctly

2019-06-19 Thread Chris Withers
with this, and then I got pulled onto another project. Chris -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full

Re: [sqlalchemy] testing that a session is committed correctly

2019-06-10 Thread Chris Withers
that transaction middleware when unit testing and then for functional testing, I just need to fall back to dropping everything in the db, or having a fresh db created from scratch? cheers, Chris -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org

Re: [sqlalchemy] testing that a session is committed correctly

2019-06-05 Thread Chris Withers
* your harness has reversed its work. Unless I'm missing something, neither of these let the test confirm that the code under test has called commit() when it should. cheers, Chris -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post

Re: [sqlalchemy] testing that a session is committed correctly

2019-06-05 Thread Chris Withers
app closes the session at the end of its request handling, which seems legit, right? How come close() doesn't rollback the SessionTransaction if it throws it away? Chris -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, plea

Re: [sqlalchemy] testing that a session is committed correctly

2019-06-05 Thread Chris Withers
rd.py", line 40, in     assert session.query(Event).count() == 0 AssertionError Whereas after the rollback, I'd expect that count to be zero... Chris -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please prov

Re: [sqlalchemy] testing that a session is committed correctly

2019-06-05 Thread Chris Withers
On 04/06/2019 23:21, Mike Bayer wrote: On Tue, Jun 4, 2019, at 4:33 PM, Chris Withers wrote: So, how do I roll back the further subtransaction created by the web framework instantiating Session from a sessionmaker bound to the connection in which begin_nested() has been called, which under

Re: [sqlalchemy] testing that a session is committed correctly

2019-06-04 Thread Chris Withers
by this. and make sure there's just the one session.   if there are two in play, I'm not sure how they both get bound to your test transaction. I believe they start a nested transaction? Chris -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post

Re: [sqlalchemy] when does session.transaction come into being?

2019-06-04 Thread Chris Withers
On 04/06/2019 14:47, Mike Bayer wrote: On Tue, Jun 4, 2019, at 3:05 AM, Chris Withers wrote: Hi All, What creates session.transaction? I can't spot get __getattr__ magic, but the only place in the code I see it being created is in .begin(...), which has a docstring saying that it should

Re: [sqlalchemy] testing that a session is committed correctly

2019-06-04 Thread Chris Withers
On 04/06/2019 14:49, Mike Bayer wrote: On Tue, Jun 4, 2019, at 2:15 AM, Chris Withers wrote: Now, what I'm trying to test is that I haven't forgotten to include the "with session.transaction". The problem is that, without the transaction.rollback(), the test passes regardless

[sqlalchemy] when does session.transaction come into being?

2019-06-04 Thread Chris Withers
Hi All, What creates session.transaction? I can't spot get __getattr__ magic, but the only place in the code I see it being created is in .begin(...), which has a docstring saying that it should no longer be used, so I feel like I must be missing something? cheers, Chris -- SQLAlchemy

[sqlalchemy] testing that a session is committed correctly

2019-06-04 Thread Chris Withers
t code under test is committing or rolling back as required? cheers, Chris -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help

[sqlalchemy] Will calling a sessionmaker or closing a session block?

2019-06-02 Thread Chris Withers
to Session, which is a sessionmaker, or db.close(), be expected to block? I can't remember whether instantiating a session will open a network connection, or whether close will similarly do network io, so thought I'd ask... Chris -- SQLAlchemy - The Python SQL Toolkit and Object Relational

Re: [sqlalchemy] Re: TypeDecorators don't know which database session to use

2019-05-30 Thread Chris Wilson
processed. I'm looking at whether something like the mutable extension would have access to the parent object, to coerce data structures containing SQLAlchemy objects into serializable form on the way into the database, and coerce them back to SQLAlchemy objects after a load event. Thanks ag

Re: [sqlalchemy] Re: TypeDecorators don't know which database session to use

2019-05-29 Thread Chris Wilson
or context was passed to the TypeDecorator then we could use it to get the session. But right now it appears that there is no hook that does what we want to do. Please would you accept my request to implement something like this? Thanks, Chris. On Tuesday, 28 May 2019 23:42:59 UTC+1, Jonathan Vanasco

[sqlalchemy] TypeDecorators don't know which database session to use

2019-05-28 Thread Chris Wilson
Dear Michael, I have discovered a limitation of TypeDecorators (custom column types): any one that uses the database (e.g. to load objects serialised in a custom way) has no way to know which database session to use. During initial load one can use a global session object, but expired

Re: [sqlalchemy] Proper way to handle new 128 character identifier limit in Oracle >= 12.2

2019-05-08 Thread Chris Stephens
I think you would actually want to query v$parameter since "compatible" can be set to a lower version than server which disables 128 lengths. SQL> select value from v$parameter where name = 'compatible'; VALUE -- 12.2.0 On Thursday, November 8, 2018 at 10:30:19 AM UTC-6, Mike Bayer

[sqlalchemy] Oracle Bulk inserts returning array of IDs possible?

2019-05-06 Thread Chris Stephens
Is is possible to implement the following behavior in SQLAlchemy against an Oracle database? (Bulk inserts returning PK IDs generated by trigger/sequence on PK column in database) #database ddl DROP TABLE INS_RET_TEST; CREATE TABLE INS_RET_TEST (ID NUMBER NOT NULL ENABLE,

[sqlalchemy] Attribute mapped collections

2018-12-19 Thread Chris Wilson
tribute-mapped ones. Thanks in advance for your consideration. Cheers, Chris. This email is confidential. If you are not the intended recipient, please advise us immediately and delete this message. The registered name of Cantab- part of GAM Systematic is Cantab Capital Partners LLP. See

Re: [sqlalchemy] Making Metadata bases more independent

2018-12-06 Thread Chris Wilson
source files. Are you looking for someone else to implement the tests? It should be easy because we already have a reproducible test case. Thanks, Chris. On Wednesday, 5 December 2018 20:24:09 UTC, Mike Bayer wrote: > > On Wed, Dec 5, 2018 at 11:04 AM Chris Wilson > > wrote: >

[sqlalchemy] Making Metadata bases more independent

2018-12-05 Thread Chris Wilson
that you would consider? Alternatively, a simpler workaround for our case, where we do not need polymorphism on the Widget class, would be to short-circuit _with_polymorphic_mappers() in such cases, so that it doesn't need to call configure_mappers at all. Thanks, Chris. This email is confidentia

Re: [sqlalchemy] context manager for session lifecycle

2018-11-25 Thread Chris Withers
On 26/11/2018 06:15, Mike Bayer wrote: On Sun, Nov 25, 2018 at 12:55 PM Chris Withers wrote: > Soat the moment you can still say this: > > with session.transaction: > > which will do the commit and rollback but not the close(). Po

Re: [sqlalchemy] context manager for session lifecycle

2018-11-25 Thread Chris Withers
On 18/11/2018 23:38, Mike Bayer wrote: On Sun, Nov 18, 2018, 6:22 PM Chris Withers <mailto:ch...@withers.org> wrote: >> Does SQLAlchemy provide a context manager that handles the session >> lifecycle described here? >> https://docs.sqla

Re: [sqlalchemy] context manager for session lifecycle

2018-11-18 Thread Chris Withers
mit the session but not close it? there's kind of too many options with the Session right now to make this one size fits all unless you have suggestions. Indeed, would you believe after almost 10 years, I think sessionmaker() finally made sense to my brain? cheers, Chris -- SQLAlchemy - The

[sqlalchemy] automated table documentation

2018-11-15 Thread Chris Frey
of this? Has this already been done? Thanks, - Chris -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description

[sqlalchemy] context manager for session lifecycle

2018-11-15 Thread Chris Withers
libraries and projects ;-) I remember Mike having good reasons against this, but I can't with them, so what would be bad about making sessions work like this: with session:    ... ...and have that do the above? cheers, Chris -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper

Re: [sqlalchemy] Using before_update and before_insert events listeners with PostgreSQL upserts

2018-10-26 Thread Chris Johnson
org/en/latest/orm/session_state_management.html#merging), > > > but that's an in-python check to see if the record already exists, > rather than allowing the DB to do it. It might work for you, depending > on how fast you need to process these messages. > > Simon > >

[sqlalchemy] Using before_update and before_insert events listeners with PostgreSQL upserts

2018-10-19 Thread Chris Johnson
Python Version: 3.6.6 SQLAlchemy version: 1.2.12 PostgreSQL version: 10.5 This is my fist time using PGSQL over MySQL or SQLite and my first project using SQLAlchemy over SQLite or the Django ORM. I'm also not very good at programming in general so please forgive the simple questions. I have a

[sqlalchemy] Objects wrongly persistent after rollback

2018-08-24 Thread Chris Wilson
eferenced list of "newly added" PKs in the outer session, instead of using _new. Thanks, Chris. This email is confidential. If you are not the intended recipient, please advise us immediately and delete this message. The registered name of Cantab- part of GAM Systematic is Cantab

Re: [sqlalchemy] Serialization / De-serialization for SQLAlchemy Declarative ORM

2018-07-11 Thread chris . modzelewski
Hi Mike, Thanks - I really appreciate it! And thanks again for all of the effort you've put into SQLAlchemy! It is a "must have" in most of the Python projects I work on these days, and I regularly sing its praises to my clients. All the best, Chris On Wednesday, July 11, 2018 at

[sqlalchemy] Serialization / De-serialization for SQLAlchemy Declarative ORM

2018-07-11 Thread chris . modzelewski
/ *GITHUB: *https://github.com/insightindustry/sqlathanor Thanks in advance, and I look forward to any thoughts or perspectives you might have! All the best, Chris -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide

Re: [sqlalchemy] adding entirely custom constraints

2018-02-01 Thread Chris Withers
awesome, thanks! On 01/02/2018 15:50, Mike Bayer wrote: On Thu, Feb 1, 2018 at 3:27 AM, Chris Withers <ch...@withers.org> wrote: Hi, So, I need to add an exclude constraint to a postgres table which has a boolean column, but: ProgrammingError: (psycopg2.ProgrammingError) data type b

[sqlalchemy] adding entirely custom constraints

2018-02-01 Thread Chris Withers
k :-/), how can I just add a constraint that I supply as text and put in __table_args__ somehow? cheers, Chris -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiab

[sqlalchemy] finding all tables with foreign keys to a model

2018-01-29 Thread Chris Withers
Hi All, How can I introspect from a declaratively mapped model all the other models/tables that have foreign keys to it? This keeps like something the ORM layer must know about... cheers, Chris -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org

Re: unit testing migration code

2017-12-14 Thread Chris Withers
Has anyone done anything like an equivalent of the following but for Alembic? https://github.com/plumdog/django_migration_testcase cheers, Chris On 01/12/2017 15:06, Mike Bayer wrote: it's kind of a PITA but in Openstack we have fixtures which actually run all the alembic (or sqlalchemy

Re: [PossibleSpam][5.0] Re: [sqlalchemy] Concise, Pythonic query syntax

2017-11-06 Thread Chris Withers
Fantastic, thanks! On 06/11/2017 22:46, Jones, Bryan wrote: All, I've just updated the package to use the MIT license. Bryan On Mon, Nov 6, 2017 at 2:22 PM, Jones, Bryan <bjo...@ece.msstate.edu <mailto:bjo...@ece.msstate.edu>> wrote: Chris, I'm open to BSD or MIT as w

Re: [sqlalchemy] Concise, Pythonic query syntax

2017-11-06 Thread Chris Withers
Great looking library, shame about the license. You particularly attached to GPL3 or would you be amenable to BSD or MIT? Chris On 03/11/2017 21:52, Bryan Jones wrote: All, I've just released the pythonic_sqlalchemy_query package on PyPI, which provides concise, Pythonic query syntax

[sqlalchemy] Intermittent psycopg2.IntegrityError errors?

2017-09-15 Thread chris
some other stuff DB.session.commit() return my_response() raise my_error() I would appreciate any and all suggestions. Thank you all in advance for your help! Regards, Chris -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy

Re: [sqlalchemy] Update timestamp with many levels of join inheritance

2017-07-31 Thread Chris Satterthwaite
! -Chris On Mon, Jul 31, 2017 at 4:05 PM, Mike Bayer <mike...@zzzcomputing.com> wrote: > On Mon, Jul 31, 2017 at 4:37 PM, Chris Satterthwaite <cnsat...@gmail.com> > wrote: > > Conceptually, what I’m trying to do is: > > > > 1) Enable queries for a higher

[sqlalchemy] Update timestamp with many levels of join inheritance

2017-07-31 Thread Chris Satterthwaite
Conceptually, what I’m trying to do is: 1) Enable queries for a higher level type (e.g. Node) to return all direct instances and sub-class instances (e.g. Node, [Servers, [UnixType, [Linux, AIX]]]) 2) Enable a set of attributes to be inherited by all sub-types 3) Enable an

Re: [sqlalchemy] mapper.order_by deprecated?

2017-05-09 Thread Chris Withers
Gotcha. Is there any way to specify a default ordering for queries against a model? (similar to that offered by the Django ORM?) cheers, Chris On 08/05/2017 23:51, mike bayer wrote: because, it only works for a really simplistic case, and for all the other cases, I have no idea what

[sqlalchemy] mapper.order_by deprecated?

2017-05-08 Thread Chris Withers
Hi All, I see mapper.order_by is deprecated in the latest release. Why is that? cheers, Chris -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http

[sqlalchemy] Forcing filters to use same type as field

2017-02-22 Thread Chris Frey
.id == 2).first() Is there any way to force the resulting SQL to use the type of Table.id instead of the integer type of 2? Or is there a better way to handle this? Thanks, - Chris -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example c

Re: adding an auto increment column to an existing table

2017-01-18 Thread Chris Withers
created as part of create_table() verus as part of an add_column()? cheers, Chris -- You received this message because you are subscribed to the Google Groups "sqlalchemy-alembic" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy-alembi

Re: [sqlalchemy] Selecting from polymorphic tables without selecting polymorphic columns

2017-01-17 Thread Chris Withers
On 17/01/2017 18:38, mike bayer wrote: On 01/17/2017 01:05 PM, Chris Withers wrote: Potentially related issue, given: class TheTable(Base): __tablename__ = 'stuff' __mapper_args__ = dict( polymorphic_on='type', polymorphic_identity='base', ) type = Column

Re: [sqlalchemy] Selecting from polymorphic tables without selecting polymorphic columns

2017-01-17 Thread Chris Withers
tests it returns nothing. self.session.query(TheTable) returns both rows, but both as TheTable instances, which I find a little surprising. Chris On 16/01/2017 17:54, mike bayer wrote: issue https://bitbucket.org/zzzeek/sqlalchemy/issues/3891/single-inh-criteria-should-be-added-for is added

Re: [sqlalchemy] single table inheritance and instrument_class events

2017-01-17 Thread Chris Withers
On 17/01/2017 15:08, mike bayer wrote: On 01/17/2017 06:15 AM, Chris Withers wrote: Great, thanks. I assume has_inherited_table returns False where the table is defined on the class itself? it looks like has_inherited_table is just looking for non-None __table__ attribute up the inheritance

Re: [sqlalchemy] single table inheritance and instrument_class events

2017-01-17 Thread Chris Withers
Great, thanks. I assume has_inherited_table returns False where the table is defined on the class itself? (ie: normal models, and the "base" model in the case of single table inheritance) Chris On 16/01/2017 17:49, mike bayer wrote: at the declarative level we have t

[sqlalchemy] single table inheritance and instrument_class events

2017-01-16 Thread Chris Withers
/b82bea1dbc1393e24116943804b192df056a70e7 ...but that feels a bit hacky. Thoughts? Chris -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http

Re: adding an auto increment column to an existing table

2017-01-10 Thread Chris Withers
le_name='observation') op.create_primary_key('observation_pkey', 'observation', ['id']) ...but how come my original attempt didn't? cheers, Chris On 10/01/2017 08:03, Chris Withers wrote: So, I screwed up and realised I really want an auto-incrementing integer as the primary key for a bu

adding an auto increment column to an existing table

2017-01-10 Thread Chris Withers
the migration, I get: sqlalchemy.exc.IntegrityError: (psycopg2.IntegrityError) column "id" contains null values [SQL: 'ALTER TABLE observation ADD COLUMN id INTEGER NOT NULL'] ...so what am I doing wrong? cheers, Chris -- You received this message because you are subscribed to the Goo

Re: [sqlalchemy] Load sqlalchemy orm model from dict

2017-01-07 Thread Chris Withers
y need to call make_transient_to_detached first so that it acts like it was loaded from the database first. Nice. Works like I wanted :) In fact, if your dict is created from a User object in the first place, I'd just keep that User object, detach it from the session and put it in your cache...

Re: patterns for automated tests of migrations

2016-12-11 Thread Chris Withers
t;, rather than your excellent but integration-y "run them all and make sure they build the expected schema". Thoughts? Chris On 23/11/2016 09:20, Tom Lazar wrote: hi chris, here’s how we do it in all our projects: https://github.com/pyfidelity/rest-seed/blob/master/backend/bac

Re: [sqlalchemy] regression with 1.1.0

2016-10-08 Thread Chris Withers
People use pg8000? ;-) I jest, but under what circumstances does pg8000 make a better choice that psycopg2? Chris On 07/10/2016 14:40, mike bayer wrote: FYI pg8000 raises ProgrammingError on these On 10/07/2016 08:56 AM, Mike Bayer wrote: On 10/07/2016 02:36 AM, Chris Withers wrote

Re: [sqlalchemy] regression with 1.1.0

2016-10-07 Thread Chris Withers
nded up with an IntegrityError) cheers, Chris -- 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 thi

[sqlalchemy] regression with 1.1.0

2016-10-06 Thread Chris Withers
and will now fail... (I guess I also have a niggle that this feels like SQLAlchemy is doing more work than it was before, will this have performance implications?) Chris -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe f

Re: [sqlalchemy] changing the order of columns in primary keys, including when generated by mixins

2016-09-22 Thread Chris Withers
On 22/09/2016 14:55, Mike Bayer wrote: On 09/22/2016 07:30 AM, Chris Withers wrote: How do you control the order in which columns are added to a multi-column primary key when using the declarative primary_key=True syntax? How about when one of those columns comes from a mixin? without mixins

[sqlalchemy] changing the order of columns in primary keys, including when generated by mixins

2016-09-22 Thread Chris Withers
Hi All, How do you control the order in which columns are added to a multi-column primary key when using the declarative primary_key=True syntax? How about when one of those columns comes from a mixin? Context is in the mail below, any help gratefully received! Chris Forwarded

[sqlalchemy] Re: Row versioning not working with multi-table polymorphism

2016-09-20 Thread Chris Wilson
provides one for us. However it had occurred to me and we might use that approach if we have problems with the event listener approach. Thanks, Chris. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this grou

[sqlalchemy] Row versioning not working with multi-table polymorphism

2016-09-20 Thread Chris Wilson
mapper.version_id_col in mapper._cols_by_table[table]: and then tries to execute a null UPDATE just in order to get the new version number, which fails. It would work if we did a dummy update, for example assigning the PK to itself, as this would change the version number (xmin) returned by the s

Re: [sqlalchemy] Turning SAWarnings into exceptions

2016-09-15 Thread Chris Withers
wrote: import warnings warnings.simplefilter("error") On 09/15/2016 08:07 AM, Chris Withers wrote: Hi All, How can I turn SAWarnings into exceptions? I'm struggling with what to put into the PYTHONWARNINGS environment variable :-S cheers, Chris -- You received this message b

[sqlalchemy] Turning SAWarnings into exceptions

2016-09-15 Thread Chris Withers
Hi All, How can I turn SAWarnings into exceptions? I'm struggling with what to put into the PYTHONWARNINGS environment variable :-S cheers, Chris -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this grou

Re: [sqlalchemy] reflecting stored procedure names, enums, and the like

2016-08-16 Thread Chris Withers
ou're just looking for a "drop everything" method I'd probably forego all that boilerplate and just have "drop_pg_sps", "drop_mysql_sps", etc. functions and key them off of engine.name in a dictionary or something. On 08/15/2016 06:16 AM, Chris Withers wrote:

[sqlalchemy] reflecting stored procedure names, enums, and the like

2016-08-15 Thread Chris Withers
/eb99d549be02643d4d670db2ee52b93b0c386fb4/mortar_rdb/__init__.py#L134 I'd like to expand to to basically delete as much as possible in a database to give a clean starting ground for tests... Chris -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubs

[sqlalchemy] chide 2.0.1 released!

2016-06-16 Thread Chris Withers
, Chris -- 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 sqlalchemy@googlegroups.

[sqlalchemy] Re: plain text versus html mail

2016-04-22 Thread Chris Withers
On 22/04/2016 03:04, Ben Finney wrote: Chris Withers <ch...@simplistix.co.uk> writes: [no text body] When posting to mailing lists, please be sure to have a plain text body with the full information. Not everyone wants to enable HTML in email just to read a software announcement :-)

[sqlalchemy] chide 2.0.0 released! - sample objects for tests

2016-04-21 Thread Chris Withers
thedocs.org/en/latest/ Development happens here: https://github.com/cjw296/chide/ cheers, Chris -- 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

Re: [sqlalchemy] where is InstanceState.key set?

2016-04-21 Thread Chris Withers
:28 PM, Chris Withers wrote: Hey All, Where is InstanceState.key set? I'm looking for the code that builds the key used in the identity_map of the session. Turns out to be not so easy to find... Chris -- You received this message because you are subscribed to the Google Groups

[sqlalchemy] where is InstanceState.key set?

2016-04-20 Thread Chris Withers
Hey All, Where is InstanceState.key set? I'm looking for the code that builds the key used in the identity_map of the session. Turns out to be not so easy to find... Chris -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubs

[sqlalchemy] tiny new tool for making sample objects for tests

2016-04-14 Thread Chris Withers
finds bugs or has suggestions, please mail me! cheers, Chris -- 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...@googlegrou

Re: [sqlalchemy] Multiple many to one relationships to same table

2016-03-19 Thread 'Chris Norman' via sqlalchemy
ue, Mar 15, 2016 at 2:12 AM, 'Chris Norman' via sqlalchemy <sqlalchemy@googlegroups.com <mailto:sqlalchemy@googlegroups.com>> wrote: Hi, On 14/03/2016 15:19, Mike Bayer wrote: On 03/14/2016 11:15 AM, 'Chris Norman' via sqlalchemy wrote: Hi all,

Re: [sqlalchemy] Multiple many to one relationships to same table

2016-03-15 Thread 'Chris Norman' via sqlalchemy
Hi, On 14/03/2016 15:19, Mike Bayer wrote: On 03/14/2016 11:15 AM, 'Chris Norman' via sqlalchemy wrote: Hi all, I've tried googling for this, and I get nothing. I have a table to store data about objects. Each object should have a location property which links back to the same table

[sqlalchemy] Multiple many to one relationships to same table

2016-03-14 Thread 'Chris Norman' via sqlalchemy
Hi all, I've tried googling for this, and I get nothing. I have a table to store data about objects. Each object should have a location property which links back to the same table. Conversely, each object should have a contents property which shows all objects which have their location set to

[sqlalchemy] Stand-alone Sequences are not created by create_all

2016-01-27 Thread Chris Macklin
If I declare a Sequence at the class level in a model class declaration using declarative (SQLAlchemy 0.9.10 on postgres), the sequence is not created by create_all unless the sequence is explicitly associated with a Column. My use case is a column which stores a URI; if a row is inserted

Re: [sqlalchemy] Stand-alone Sequences are not created by create_all

2016-01-27 Thread Chris Macklin
that makes it clear *how* to achieve this association. On Wed, Jan 27, 2016 at 11:49 AM, Simon King <si...@simonking.org.uk> wrote: > > > On 27 Jan 2016, at 18:59, Chris Macklin <chris.mack...@gmail.com> wrote: > > > > If I declare a Sequence at the class level in

Re: [sqlalchemy] Re: Connection pools

2016-01-06 Thread Chris Wood
, Chris On Tuesday, 22 December 2015 12:02:40 UTC, Chris Wood wrote: > > > > On Tuesday, 22 December 2015 01:53:59 UTC, Michael Bayer wrote: >> >> >> >> On 12/21/2015 07:44 PM, Chris Wood wrote: >> > Ah, ok - thanks for the explanation - this is different t

Re: [sqlalchemy] in-place modification of queries?

2015-12-30 Thread Chris Withers
, Chris On 28/12/2015 15:22, Mike Bayer wrote: not through the current API, no. you'd need to write some modifier to the @generative decorator and basically tinker with things to make it do that. On 12/28/2015 06:18 AM, Chris Withers wrote: Hi All

[sqlalchemy] in-place modification of queries?

2015-12-28 Thread Chris Withers
Hi All, Is there anything I can do to make Query instance non-generative? query = session.query(Foo) query.filter(Foo.x==1) ...and have the query actually be modified rather than returning a new query with the clause added? cheers, Chris -- You received this message because you

Re: [sqlalchemy] can I use tables generated by ORM via sql expression language for select queries

2015-12-27 Thread Chris Withers
can get the sql expression language - compatible table from your Base-inheriting class as follows: YourClass.__table__ cheers, Chris -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving e

Re: [sqlalchemy] Re: Connection pools

2015-12-22 Thread Chris Wood
On Tuesday, 22 December 2015 01:53:59 UTC, Michael Bayer wrote: > > > > On 12/21/2015 07:44 PM, Chris Wood wrote: > > Ah, ok - thanks for the explanation - this is different to how I'd been > > led to believe it worked! However, I know that even when I'm the

[sqlalchemy] Re: Connection pools

2015-12-21 Thread Chris Wood
Ah, ok - thanks for the explanation - this is different to how I'd been led to believe it worked! However, I know that even when I'm the only person testing the application, I'm still getting a large number of connections. Is there a likely explanation why? On Monday, 21 December 2015 18:51:25

[sqlalchemy] Connection pools

2015-12-21 Thread Chris Wood
ow at a total loss of what to try next. I clearly have failed to understand some major aspects of connections / pooling - any help or pointers to help me sort out the number of connections would be majorly appreciated! Thanks, Chris -- You received this message because you are subscribed to the

[sqlalchemy] postgres "similar to" in sqlalchemy expressions

2015-12-11 Thread Chris Withers
Hi All, Just wanted to double check, is this still the best way to do this: https://groups.google.com/forum/#!topic/sqlalchemy/6kZaWeqTpHA foo.op("SIMILAR TO")(bar) cheers, Chris -- You received this message b

  1   2   3   4   5   6   >