Re: [sqlalchemy] Baked Query with Bound Entity/FromClause

2021-03-31 Thread Scott Colby
d ensure that "model" is a long lived object , e.g. a mapped > class. If it's an aliased() object, I'd make sure to use the same > aliased() object each time. > Adding an additional positional argument to augment the cache key worked perfectly for my use case. I am indeed using a s

[sqlalchemy] Baked Query with Bound Entity/FromClause

2021-03-31 Thread Scott Colby
rnative approach that would allow me to continue to use baked queries while not having to implement a separate *_entities_created() for every model I'm interested in? The next problem would then be how to refer to model.created_at within the filter clause. Can that be handled with a bindparam too?

Re: [sqlalchemy] Create Sqlalchemy ORM class from regular class gets "has no attribute ''_sa_instance_state''"

2021-03-18 Thread Scott Faurholm
Yes, sorry I didn't follow up On Mon, Mar 15, 2021 at 12:28 PM Simon King wrote: > I haven't followed your code in detail, but I think the problem might be > here: > > clazz = school.Class('12', 'A') > > students = [ > Student("Name1", "Sname1", clazz=clazz, code='aa7'), >

Snowflake odities and ReplaceableObject

2019-10-11 Thread Scott
. I can hack something together with a superclass, but though I would mention here in case someone has a cleaner solution. Cheers, Scott -- You received this message because you are subscribed to the Google Groups "sqlalchemy-alembic" group. To unsubscribe from this group and stop re

Re: [sqlalchemy] Creating Namespaced/Gapless Sequences Using Event Listeners

2019-10-08 Thread Scott Colby
quot;namespaced sequence factory" which I think might be cool. I’ll post it to the group here if it works out. Thanks again, Scott Colby On Oct 4, 2019, 19:12 -0400, Mike Bayer , wrote: > > > On Fri, Oct 4, 2019, at 3:57 PM, Scott Colby wrote: > > Hello, > > > > I am att

[sqlalchemy] Creating Namespaced/Gapless Sequences Using Event Listeners

2019-10-04 Thread Scott Colby
`RETURNING` clause or `SELECT FOR UPDATE` but I would prefer to only have one code path for PostgresSQL and SQLite (and others?) if possible. Unfortunately, I'm stumped as how to do this. What is the right approach to implement this pattern? Thank you, Scott Colby -- SQLAlchemy - The Python SQL To

Re: Alembic: Varying database names per environment?

2019-08-19 Thread Scott
On Monday, August 19, 2019 at 9:58:19 AM UTC+10, Mike Bayer wrote: > > > > On Sun, Aug 18, 2019, at 6:50 PM, Scott wrote: > > Looking to use Alembic to manage migrations. > > We currently have different database names in each environment, so for > dev, test and p

Alembic: Varying database names per environment?

2019-08-18 Thread Scott
the environment suffix? Thanks, Scott -- 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

Re: [sqlalchemy] ROLLBACK not happening with transaction in test suite

2018-06-01 Thread Scott Colby
, _sqlite3_Connection): # emit our own BEGIN logger.debug('emitting our own BEGIN to work around pysqlite bug') connection.execute('BEGIN') My only other question is, for future debugging, where should I log to get *all* the SQL that is ultimately passed to the database? Thanks, Scott

[sqlalchemy] ROLLBACK not happening with transaction in test suite

2018-05-28 Thread Scott Colby
to use here, but that is how the real code works and I want to test in a similar environment; additionally, when I tried this whole exercise with a normal `sessionmaker`, all these problems happened in an identical manner.) Thanks, Scott Colby -- SQLAlchemy - The Python SQL Toolkit

[sqlalchemy] Possible bug with populating backref collections

2017-01-27 Thread Philip Scott
I think it's easier to explain in an example than for me to waffle on trying to explain myself :) from sqlalchemy import Column, ForeignKey, Integer, create_engine from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import relationship, Session Base = declarative_base()

Re: [sqlalchemy] Using sessions in a GUI application

2017-01-21 Thread Philip Scott
> > > It's possible that if you're using the session in "autocommit" mode and > just want to occasionally "broadcast" your object state to a quick > "flush everything", that in fact turning off the "accounting" feature > with this flag is appropriate. I'm looking at this code and it really

Re: [sqlalchemy] Using sessions in a GUI application

2017-01-20 Thread Philip Scott
Hi Mike Thank you for your quick and thoughtful response as usual! > so the quick and dirty approach is a flag I'm not enthused about, > nevertheless I don't plan on removing, called > _enable_transaction_accounting, > Yes I saw this when poking around in the source code - it does seem like

[sqlalchemy] Using sessions in a GUI application

2017-01-20 Thread Philip Scott
Hello all, Short summary of my question: Is it possible to stop rollback() from expiring dirty objects? Specifically, in the case where there are - local changes made outside to mapped objects outside of a transaction - flush() is called - the flush fails In this case SQLAlchemy will

Re: [sqlalchemy] Nested transaction rollback does not undo changes to instances

2015-04-09 Thread Philip Scott
(Chris's colleague here) On Thursday, 2 April 2015 17:23:13 UTC+1, Michael Bayer wrote: this issue is fixed for 0.9.10 and 1.0.0b5, you can test now using either latest master or the rel_0_9 branch. Just wanted to say thank you very much for the prompt fix; I continue to be amazed at

[sqlalchemy] Automatically Adding M2M on append causing UNIQUE constraint violation

2014-08-06 Thread Cody Scott
I have an intermediate model which I am using to keep track of which labs to include since individual labs can be removed. So when you add a new intermediate model (AgendaModel) it automatically adds all of the labs. with @event.listens_for(Agenda.modules, 'append') But there is a UNIQUE

Re: [sqlalchemy] List Objects To Be Deleted

2014-07-15 Thread Scott Meisburger
then see that by just getattr(someobj, “somekey”). On Jul 15, 2014, at 3:40 PM, Scott Meisburger smeis...@gmail.com javascript: wrote: I've got an app where through an admin interface, a user can delete objects in the database. This happens via: db.session.delete(obj) db.session.commit

[sqlalchemy] Automatically populate Association Object Field

2014-07-04 Thread Cody Scott
I have a Many-to-Many relationship that I would like to keep track of the order. I am wondering if I can automatically populate the module_position field based on the current number of AgendaModule's for an Agenda. class AgendaModule(db.Model): __tablename__ = 'agenda_modules'

[sqlalchemy] unable to open database file

2014-06-19 Thread Scott Horowitz
Hi, A user of my applicable is getting a unable to open database file None None error because the file path to their database has a Á character in it. It works fine if the character is removed, but that is not a good solution. Does anyone know how to solve this? Thanks, Scott -- You

Re: [sqlalchemy] unable to open database file

2014-06-19 Thread Scott Horowitz
works: if filename != ':memory:': filename = os.path.abspath(filename) I am going to file a bug report to see if this should/could be changed (I'm not sure if there are any downsides to removing these lines). Scott On Thursday, June 19, 2014 12:48:57 PM UTC-6, Michael Bayer wrote

Re: [sqlalchemy] unable to open database file

2014-06-19 Thread Scott Horowitz
Ah great, that is much better than having to modify sqlalchemy code. Indeed, the below code works for me: os.chdir(os.path.dirname(db_path)) e = create_engine(sqlite:///, creator=lambda: sqlite3.connect(os.path.basename(db_path))) Thanks! Scott On Thu, Jun 19, 2014 at 2:09 PM, Mike Bayer mike

[sqlalchemy] Oracle with sequence for primary key and that sequence out of sync

2014-06-02 Thread Scott Koranda
() class. I would be grateful for any insights on how the sequence might have become out of sync or anything I can change in the code to prevent it from happening again. Thank you for your consideration. Scott P.S. I should add that I am using cx_Oracle and the connection string oracle+cx_oracle

Re: [sqlalchemy] joinedload()

2014-03-25 Thread Philip Scott
...@zzzcomputing.comwrote: On Mar 24, 2014, at 2:09 PM, Philip Scott safetyfirstp...@gmail.com wrote: Is this a bug, or perhaps some expected side effect of the joined load? seemed like something that might be possible but the scalar loader is initializing the attribute to None to start

Re: [sqlalchemy] joinedload()

2014-03-25 Thread Philip Scott
at 1:06 PM, Michael Bayer mike...@zzzcomputing.comwrote: On Mar 25, 2014, at 7:48 AM, Philip Scott safetyfirstp...@gmail.com wrote: Ah, so, it turns out to be more subtle than I first thought. It took me quite a while to narrow it down to an easily reproducible case. To trigger the behavior

[sqlalchemy] joinedload()

2014-03-24 Thread Philip Scott
Hello all, I am trying to optimize a query I have, and have noticed some strange behavior. I have a table called 'Trade'. A trade may optionally have a commission, which itself is a trade. This is the core of it: class Trade(Base, CCPTableMixin): __tablename__= trade id

[sqlalchemy] matches_any: an extension to the Query object, and a HSTORE attribute access property

2014-01-07 Thread Philip Scott
Hi folks, SQLAlchemy is at the heart of what we do at work (UK based hedge fund); so first of all a big thank you; I am not quite sure where we'd be without you. We would like to give back to the community as much as we can (I tried to get some of the developers on the company xmas present

Re: [sqlalchemy] load events with polymorphic_on

2013-09-23 Thread Philip Scott
this is normal, loading for the base class only hits those columns which are defined for that base class - it does not automatically fan out to all columns mapped by all subclasses. to do so, you can specify with_polymorphic: Ahh, thank you very much Michael that does do exactly what I want.

Re: [sqlalchemy] What is declarative_base() exactly?

2013-09-23 Thread Philip Scott
declarative_base is just a function that returns a class. In python, a class is a first class object just like any other. You can do things like this: class MyClass(object): pass def foo() return MyClass my_class_instance = foo()() In normal use of SQLAlchemy you don't need to think too

Re: [sqlalchemy] another postgresql distinct on question

2013-09-23 Thread Philip Scott
I went though the exact same process of discovery that you did Jonathan :) It does work perfectly but does not get rendered properly when printing out the queries (possibly even when I set echo=True on the connection, if I remember correctly) On Sun, Sep 22, 2013 at 5:44 PM, Jonathan Vanasco

Re: [sqlalchemy] Mutable column_properties

2013-09-23 Thread Philip Scott
Scott safetyfirstp...@gmail.com wrote: Without actually querying the DB or enumerating the types and their conversions myself which seems a bit naff; psycopg2.extensions.adapt almost does it but not quite (e.g. you get '2013-09-10'::date when CAST() gives you 2013-09-10). Any ideas? It's

Re: [sqlalchemy] Mutable column_properties

2013-09-20 Thread Philip Scott
| Philip - does this help you at all ? I used the ORM to access the connection and table data in the underlying engine. Thank you for your help guys, it was very helpful! HSTORE updating does work nicely; I've ended up using events as Michael suggested, except that I have hooked into the

[sqlalchemy] load events with polymorphic_on

2013-09-20 Thread Philip Scott
Hello again dear list, I have a mapped class is polymorphic with single table inheritance. I have a function wired up to the load() SA event. The dictionary in the InstanceState which is passed to the load event depends on whether I am querying on the base class or a derived one, which I don't

Re: [sqlalchemy] Mutable column_properties

2013-09-12 Thread Philip Scott
Thanks Michael a column_property() against a SQL expression by definition is not writable. Your table doesn't have a CAST trigger inside of it for when an int is written to it that would convert it back to a string. in this case since data is already loaded fully as a single column you

[sqlalchemy] Mutable column_properties

2013-09-11 Thread Philip Scott
Hi Folks, So we have a sort of generic table; let's call it 'Thing'. For the sake of example, let it have two columns. An integer 'id', and a hstore 'data': from sqlalchemy.dialects.postgresql import HSTORE from Column, Integer class Thing(Base): __tablename__ = 'thing' id =

Re: [sqlalchemy] Difficulty using dynamic schemas (ENUM is schema-stubborn). Patch?

2013-01-28 Thread Scott Sadler
On Sunday, 27 January 2013 23:10:20 UTC, Michael Bayer wrote: On Jan 27, 2013, at 4:42 PM, Scott Sadler wrote: Hi, I wanted to post here since I had to hack around an issue in order to use SQLAlchemy with a dynamic Postgres schema, and I wanted to see if there's a way I can get

[sqlalchemy] Difficulty using dynamic schemas (ENUM is schema-stubborn). Patch?

2013-01-27 Thread Scott Sadler
Hi, I wanted to post here since I had to hack around an issue in order to use SQLAlchemy with a dynamic Postgres schema, and I wanted to see if there's a way I can get the workarounds out of my code. In my app I'm separating the data by dynamically managing the schemas. The basic way this is

[sqlalchemy] generalized polymorphic mixin

2011-01-26 Thread scott
.__bases__: ret['polymorphic_on'] = PolymorphicMixin.discriminator return ret Thanks, Scott -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from

[sqlalchemy] Reflection fails on binary columns in sqlite

2011-01-12 Thread scott
is below. I don't really know enough about the types system to know if this is something I'm doing wrong or something sqlalchemy is doing wrong, but it seems to have been introduced in r7154: http://hg.sqlalchemy.org/sqlalchemy/rev/e409e3adb99f Thanks! Scott $ sqlite3 foo.db SQLite version 3.6.12

[sqlalchemy] Re: filtering with an association_proxy

2009-11-18 Thread scott
Great, thanks, I found a ticket that was already open for this and added to it. http://www.sqlalchemy.org/trac/ticket/1372 On Nov 17, 7:23 am, Michael Bayer mike...@zzzcomputing.com wrote: scott wrote: Is there a way to filter a query involving an association_proxy? For example, say I

[sqlalchemy] filtering with an association_proxy

2009-11-16 Thread scott
(), with tests. I'm happy to post a ticket and flesh it out more if it seems reasonable. http://web.mit.edu/storborg/Public/better-associationproxy-filtering.patch Thanks, Scott --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google

[sqlalchemy] filtering/ordering with composite columns

2009-06-13 Thread Scott Torborg
don't really know what the underlying column name is going to be for each instance of a composite column type. session.query(Vertex).order_by(vertices.c.x1) Thanks, Scott --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google

[sqlalchemy] deferred columns can't be added to declarative class after creation?

2009-04-15 Thread scott
for this? Thanks! Scott example of (bug?) in adding deferred columns to a declarative class after the class's creation. Foo is a normal declarative class with a deferred column. Bar is the same class, but with the deferred column added afterwards. from sqlalchemy import * from sqlalchemy.orm

[sqlalchemy] Re: Using order_by in an association many-to-many relationship with columns from the association object

2009-03-11 Thread Scott
to access a non-foreign key column on the join table to order the collection by. If there's a better way to do this with the order_by parameter I'd love to figure it out b/c association object syntax with ORM gets REALLY messy. Thanks, Scott On Mar 10, 12:03 pm, Michael Bayer mike...@zzzcomputing.com

[sqlalchemy] Using order_by in an association many-to-many relationship with columns from the association object

2009-03-10 Thread Scott
'. Any advice would be appreciated! Scott --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email

[sqlalchemy] SqlSoup many-to-many relation causes insert into association table?

2009-03-06 Thread Scott Torborg
) NOT NULL, Category1 CHAR(2), Category2 CHAR(2) ) The user I'm connecting with does not have INSERT privileges, so a DatabaseError is raised when db.Products.first() is called and SA tries to do the INSERT. Any idea why SA is trying to do this? Thanks! Scott Traceback (most recent call last

[sqlalchemy] Re: SqlSoup many-to-many relation causes insert into association table?

2009-03-06 Thread Scott Torborg
=db.Products.c.ManProdCode == db.ProductCategory.c.ManProdCode, secondaryjoin=db.ProductCategory.c.Category1 == db.Categories.c.CatCode, foreign_keys=[db.ProductCategory.c.ManProdCode, db.ProductCategory.c.Category1]) Cheers, Scott On Mar 6, 2:49 pm, Scott Torborg storb

[sqlalchemy] Re: Confused about relations

2007-12-12 Thread Scott Graham
that, it would just all work out. Thanks again, I should have rtfm'd better for this one. scott --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy

[sqlalchemy] Confused about relations

2007-12-11 Thread Scott Graham
, seem to be ok at that point. Is there something dumb that I've set up wrong that someone could point me at? Or is this just a gotcha to be avoided? thanks, scott --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups

[sqlalchemy] Two MSSQL databases on one engine?

2007-10-25 Thread Scott Jaderholm
, but in database2 not database1. Is there a way to do this without defining another engine? It looks like Table will take a schema in the table name argument but not another database name. Thank you, Scott --~--~-~--~~~---~--~~ You received this message because you

[sqlalchemy] MSSQL connection url format?

2007-09-17 Thread Scott Jaderholm
tables - in the DB used by the ERP system - in a new DB on the same MSSQL server - in a SQLite DB How easy does SA make it to use data from multiple DBs? Thank you very much for your help and work on SQLAlchemy, Scott --~--~-~--~~~---~--~~ You received this message

[sqlalchemy] Re: alias table names with a self-ref join

2007-09-09 Thread Scott Beardsley
. Scott --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options