Re: [sqlalchemy] NoneType not callable exception

2016-02-19 Thread Mike Bayer
On Fri, Feb 19, 2016 at 9:30 PM, wrote: > My company is in the process of upgrading one of our applications from > SQLAlchemy 0.9 to 1.0.12. The process is mostly complete but we are getting > exceptions seemingly at random for some of our more complicated queries. > > The

Re: [sqlalchemy] NoneType not callable exception

2016-02-19 Thread Mike Bayer
On Fri, Feb 19, 2016 at 9:30 PM, wrote: > > The issue seems to be occurring for queries where we use the add_entity() > method > to select a declarative model entity when a column from the same table is > already in the query constructor and labeled. > just to make sure,

Re: [sqlalchemy] How do I start a transaction without regard to whether it is nested or not?

2016-02-19 Thread Mike Bayer
On Fri, Feb 19, 2016 at 1:12 PM, Daniel Fortunov < googlegro...@danielfortunov.com> wrote: > Context > > I would like to make use of nested transactions using SQLAlchemy (in > postgres), but I want to write an independent function that doesn't care if > the session already has a transaction or

Re: [sqlalchemy] NoneType not callable exception

2016-02-19 Thread Mike Bayer
had encountered something similar before. I'll keep trying to get that MCVE "working".. Thanks, Bill On Fri, Feb 19, 2016 at 11:13 PM, Mike Bayer <clas...@zzzcomputing.com <mailto:clas...@zzzcomputing.com>> wrote: On Fri, Feb 19, 2016 at 9:30 P

Re: [sqlalchemy] NoneType not callable exception

2016-02-20 Thread Mike Bayer
On 02/20/2016 12:28 AM, Mike Bayer wrote: On 02/19/2016 11:52 PM, bill.ad...@level12.io wrote: I got a test case working. It seems that the limit/offset operations have an effect. The script fails less than half the time and so far only fails when I run python with the -R flag

Re: [sqlalchemy] hang on connect in forked process

2016-02-21 Thread Mike Bayer
n is doing things, that would have to be fully demonstrated in isolation and analyzed. On Thursday, February 18, 2016 at 6:24:40 PM UTC-8, Mike Bayer wrote: On 02/18/2016 01:39 PM, Uri Okrent wrote: > Looks like forking from a thread causes other issues. I think I've

Re: [sqlalchemy] alembic del sys.modules[module_id] leading to orm mapper error

2016-02-21 Thread Mike Bayer
Hi there - Can you post a stack trace, and also is your test suite making use of clear_mappers() ? The sys.modules activity is not really the primary cause, it's that alembic makes use of a module object in a temporary way. > On Feb 21, 2016, at 1:48 PM, Will Angenent

Re: [sqlalchemy] alembic del sys.modules[module_id] leading to orm mapper error

2016-02-21 Thread Mike Bayer
ame__ were None. Thanks, Will On 21 Feb 2016, at 19:12, Mike Bayer <clas...@zzzcomputing.com <mailto:clas...@zzzcomputing.com>> wrote: Hi there - Can you post a stack trace, and also is your test suite making use of clear_mappers() ? The sys.modules activity is not really t

Re: [sqlalchemy] Is it possible to use a Comparator to override a database/SQL-side comparison symmetrically?

2016-02-12 Thread Mike Bayer
On 02/12/2016 02:29 AM, immerrr again wrote: On Thu, Feb 11, 2016 at 8:48 PM, Mike Bayer <mike...@zzzcomputing.com> wrote: Good point, but this may not be an option. Currently we return NULLTYPE for such ambigious comparisons but it's not known what side effects would occur if we

Re: [sqlalchemy] Is it possible to use a Comparator to override a database/SQL-side comparison symmetrically?

2016-02-11 Thread Mike Bayer
On 02/11/2016 01:16 PM, immerrr again wrote: > well Python only allows one side's operator override to be called, so > when DateTime is on the left, its own operate() method is called and not > yours. Excuse me for barging in, but the operator function can return a "NotImplemented"

Re: [sqlalchemy] Re: properties of query results if names overlap?

2016-03-09 Thread Mike Bayer
the name overlap situation is much improved in 1.1 to where it almost doesn't matter anymore: http://docs.sqlalchemy.org/en/latest/changelog/migration_11.html#positional-matching-is-trusted-over-name-based-matching-for-core-orm-sql-constructs On 03/09/2016 05:40 PM, Alex Hall wrote: I think

Re: [sqlalchemy] reflection fails on table with name in all caps

2016-03-14 Thread Mike Bayer
ly change was when I put my declaration of base below the class, and Python naturally said it didn't know what my table class was inheriting from. I don't know why this is being such a problem. On 3/14/16, Mike Bayer <clas...@zzzcomputing.com> wrote: oh. try it like this: class VENDR(base):

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

2016-03-14 Thread Mike Bayer
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. Conversely, each object should have a contents

Re: [sqlalchemy] Does dynamic loading effect speed?

2016-03-14 Thread Mike Bayer
On 03/13/2016 04:46 PM, Kate Boelhauf wrote: I just learned about dynamic loading and was able to implement that so that I could filter on a relationship matched_objects = foo.relationship.filter(RelationshipClass.property =="mustmatch").all() if len(matched_objects) > 0: continue

Re: [sqlalchemy] Re: Database synchronisation

2016-03-18 Thread Mike Bayer
marca 2016 16:56:05 UTC+1 Mike Bayer napísal(-a): how about: from sqlalchemy import inspect mapper = inspect(obj) session.expire(obj, [col.key for col in mapper.primary_keys]) make_transient(obj) On 03/17/2016 10:54 AM, milan5...@gmail.com wrote: > Righ

Re: [sqlalchemy] Re: Database synchronisation

2016-03-18 Thread Mike Bayer
how about: from sqlalchemy import inspect mapper = inspect(obj) session.expire(obj, [col.key for col in mapper.primary_keys]) make_transient(obj) On 03/17/2016 10:54 AM, milan53064...@gmail.com wrote: Right now I am taking test run object from local database, then I call expunge

Re: [sqlalchemy] Modeling single FK to multiple tables

2016-03-18 Thread Mike Bayer
On 03/17/2016 03:11 PM, Alex Hall wrote: Hello all, It seems like I can't go a day without running into some kind of wall. This one is a conceptual one regarding foreign keys. I have to somehow get the same FK column in table A pointing to IDs in tables B and C. So a real foreign key

Re: [sqlalchemy] reflection fails on table with name in all caps

2016-03-11 Thread Mike Bayer
itions for the other columns if I did that. I'm further guessing that this replaces the docs' method of subclassing, since the PK is now set. However, I don't know if this would still work with automapping. On 3/11/16, Mike Bayer <clas...@zzzcomputing.com> wrote: ah. does VENDR have a primary

Re: [sqlalchemy] reflection fails on table with name in all caps

2016-03-11 Thread Mike Bayer
kind of thing, only query it. On 3/11/16, Mike Bayer <clas...@zzzcomputing.com> wrote: just make the class and include the PK column, then automap. the rest of the columns should be filled in. On 03/11/2016 04:14 PM, Alex Hall wrote: Ah, you're right. Every other table I've used in t

Re: [sqlalchemy] session flush inserts performing VERY slow for MS Sql Server

2016-03-09 Thread Mike Bayer
On 03/09/2016 11:56 AM, jbrownst...@clearcosthealth.com wrote: This is all extremely helpful. After some hair pulling I was able to get the local sql server express running and I ran the same test on a local instance. 10100.1260.0000.1260.000 {method 'execute' of

Re: [sqlalchemy] Select * but apply distinct to one column

2016-03-09 Thread Mike Bayer
On 03/09/2016 01:38 PM, Alex Hall wrote: Hi all, I want to select * from a table, getting all columns. However, the only rows I want are where the item number is distinct. I've got: items = session.query(itemTable)\ .distinct()\ .limit(10) But that doesn't apply "distinct" to just item_number.

Re: [sqlalchemy] mssql: UnicodeDecodeError: 'utf8' codec can't decode byte

2016-03-09 Thread Mike Bayer
query.py", line 3523, in proc return row[column] UnicodeDecodeError: 'utf8' codec can't decode byte 0x93 in position 506: invalid start byte On Sunday, March 6, 2016 at 6:59:44 PM UTC-5, Mike Bayer wrote: Can you share a stack trace please ? Encoding

Re: [sqlalchemy] mssql: UnicodeDecodeError: 'utf8' codec can't decode byte

2016-03-09 Thread Mike Bayer
usted_connection=yes=utf8_large_types=True_unicode=True On Wednesday, March 9, 2016 at 2:49:35 PM UTC-5, Mike Bayer wrote: OK what you can try here that might resolve all the issues is to only pass encoded utf8 to the app (and also receive it on the way back); you can do that by setting

Re: [sqlalchemy] session flush inserts performing VERY slow for MS Sql Server

2016-03-08 Thread Mike Bayer
tein wrote: Thanks Mike - will the full profile ASAP. On Monday, March 7, 2016, Mike Bayer <clas...@zzzcomputing.com <mailto:clas...@zzzcomputing.com>> wrote: What will make inserts slow is network as well as indexes. If you aren't comparing your script

Re: [sqlalchemy] Re: Error dropping table with sequence on Postgres

2016-03-11 Thread Mike Bayer
I've created https://bitbucket.org/zzzeek/sqlalchemy/issues/3676/defaults-sequences-assigned-to-both-python in the hopes I can look at this at some point. On 03/11/2016 02:44 PM, Jay Camp wrote: Thanks for the explanation. It makes sense now. To restate what you said this won't work

Re: [sqlalchemy] Self referential table, with composite key, and relationship(..., lazy='joined') is not eager loading as expected.

2016-03-12 Thread Mike Bayer
Self-referential lazy="joined" requires the join_depth argument. Check the docs. > On Mar 12, 2016, at 6:22 PM, Devin Jacobs wrote: > > from sqlalchemy import Column, and_ > from sqlalchemy import create_engine, Integer, String, Date, Enum > from sqlalchemy.orm import

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

2016-03-19 Thread Mike Bayer
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 defaults be selectables which reference other

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

2016-03-19 Thread Mike Bayer
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 defaults be selectables which reference other tables while avoiding circular imports. To avoid circular imports I cannot always build the selects at import

Re: [sqlalchemy] reflection fails on table with name in all caps

2016-03-11 Thread Mike Bayer
On 03/11/2016 09:39 AM, Alex Hall wrote: Hello list, Finally, a pure SA question from me. I'm using Automap and the "only" keyword to automap a subset of the tables in our CMS database. This has worked perfectly thus far. Now, though, it's failing on a specific table, and the only difference I

Re: [sqlalchemy] reflection fails on table with name in all caps

2016-03-11 Thread Mike Bayer
On 3/11/16, Mike Bayer <clas...@zzzcomputing.com> wrote: On 03/11/2016 09:39 AM, Alex Hall wrote: Hello list, Finally, a pure SA question from me. I'm using Automap and the "only" keyword to automap a subset of the tables in our CMS database. This has worked perfectly thus far.

Re: [sqlalchemy] reflection fails on table with name in all caps

2016-03-11 Thread Mike Bayer
. On 3/11/16, Mike Bayer <clas...@zzzcomputing.com> wrote: can you look in metadata.tables to see what it actually reflected ? On 03/11/2016 12:09 PM, Alex Hall wrote: That's weird: the name I see is exactly what I've been using, "VENDR". All caps and everything. I tried

[sqlalchemy] Alembic 0.8.5 Released

2016-03-09 Thread Mike Bayer
Alembic 0.8.5 is now available. Version 0.8.5 includes a short set of bugfixes. See http://alembic.readthedocs.org/en/latest/changelog.html#change-0.8.5. Download Alembic 0.8.5 at: https://pypi.python.org/pypi/alembic -- You received this message because you are subscribed to the Google

Re: [sqlalchemy] Error dropping table with sequence on Postgres

2016-03-10 Thread Mike Bayer
On 03/10/2016 09:52 PM, Jay Camp wrote: Postgres: 9.4 SQLAlchemy: 1.0.11 When a sequence is created against a column, calling `metadata.drop_all()` tries to drop the sequence before dropping the table and fails because the table is still referencing the sequence. Manually dropping the table

Re: [sqlalchemy] Determining what, if anything, a Session.merge() does?

2016-03-10 Thread Mike Bayer
On 03/10/2016 08:06 PM, Russ wrote: Is there any way to tell what the outcome of a Session.merge() operation is? The case of specific interest is when the instance to be merged *does* exist prior to the merge() call. Is there a built in way to see if any attributes end up updated, or does

Re: [sqlalchemy] reflection fails on table with name in all caps

2016-03-14 Thread Mike Bayer
rTable = base.classes.VENDR #AttributeError: VENDR I still don't quite see how base, metadata, and session all interact to do what SA does, or I'd have a much easier time troubleshooting this. I'm sure I just have something out of order, or some other simple mistake. On 3/11/16, Mike Bayer <clas...

Re: [sqlalchemy] Executing callback after current transaction commit unless rollback occurs

2016-03-29 Thread Mike Bayer
:45 PM UTC+3, Mike Bayer wrote: On 03/29/2016 12:32 AM, Yegor Roganov wrote: > Thanks Mike > > Unfortunately it seems that after_transaction_end event executes twice: > right before COMMIT and after after_commit event. Here what I see with > ech

Re: [sqlalchemy] Executing callback after current transaction commit unless rollback occurs

2016-03-28 Thread Mike Bayer
On 03/28/2016 03:21 PM, Yegor Roganov wrote: I would like to get what I described in the subject: attach an event listener that will execute once after current transaction's successful commit (analogue to django's on_commit

Re: [sqlalchemy] scoped_session, sessions and thread safety

2016-03-30 Thread Mike Bayer
On 03/30/2016 12:37 PM, Mehdi GMIRA wrote: I've read a lot of stuff on scoped_session, thread safety, and sessions, and i just don't get it. For me, a session is just a "wrapper" around the actual database behind it. And databases do not like concurrent updates of the same row within multiple

Re: [sqlalchemy] relationships, potentially large collections and eagerloading/bad dbs.

2016-03-30 Thread Mike Bayer
On 03/30/2016 11:56 AM, Jonathan Vanasco wrote: On Wednesday, March 30, 2016 at 12:46:01 AM UTC-4, Mike Bayer wrote: why can't you build a relationship() which has its primaryjoin set up to do this? You can do it w/ a correlated subquery. Can you reference an example ? from

Re: [sqlalchemy] information schema with sqlalchemy and pymssql reflection and case sensitivity issue

2016-04-05 Thread Mike Bayer
.7/site-packages/sqlalchemy/util/deprecations.py", line 106, in warned return fn(*args, **kwargs) File "/Users/adv/anaconda/lib/python2.7/site-packages/sqlalchemy/sql/schema.py", line 90, in quote return self.name.quote AttributeError: 'MetaData' object has no attribute 'name'

Re: [sqlalchemy] Support for Oracle 12c auto increment (IDENTITY) columns?

2016-04-13 Thread Mike Bayer
On 04/13/2016 07:50 AM, Piotr Dobrogost wrote: Mike, Thanks for your reply! On Wednesday, April 13, 2016 at 1:15:32 PM UTC+2, Mike Bayer wrote: We've not started supporting new oracle 12c features as of yet, in this case it might be possible to get it working with some dialect

Re: [sqlalchemy] Support for Oracle 12c auto increment (IDENTITY) columns?

2016-04-13 Thread Mike Bayer
rt for Oracle 12c auto increment (IDENTITY) columns? Mike, Thanks for your reply! On Wednesday, April 13, 2016 at 1:15:32 PM UTC+2, Mike Bayer wrote: We've not started supporting new oracle 12c features as of yet, in this case it might be possible to get it working with

Re: [sqlalchemy] Support for Oracle 12c auto increment (IDENTITY) columns?

2016-04-13 Thread Mike Bayer
We've not started supporting new oracle 12c features as of yet, in this case it might be possible to get it working with some dialect flags since we already use "returning" to get at the newly generated primary key, although testing would be needed and other assumptions in the dialect might get in

Re: [sqlalchemy] Feedback on "Basic Relationship Patterns" docs

2016-04-11 Thread Mike Bayer
On 04/11/2016 09:58 AM, Ryan Govostes wrote: Hi, I'm a beginner reading the "Basic Relationship Patterns" documentation: http://docs.sqlalchemy.org/en/latest/orm/basic_relationships.html The examples are confusing to me because all of the examples use "Parent" and "Child," which in reality

Re: [sqlalchemy] Marshmallow Sqlalchemy

2016-04-11 Thread Mike Bayer
please send questions for third party packages to the maintainers of those packages, in this case the github page for this project. On 04/11/2016 10:15 AM, Shankar Ganesh wrote: Hi, Is there a way to avoid inserting the data into session while using Marshmallow - sqlalchemy sqlalchemy

Re: [sqlalchemy] Optimally access a model paramater n number of relationships away

2016-04-10 Thread Mike Bayer
On 04/06/2016 06:55 PM, Brian Leach wrote: Hi everyone! I have asked this question on StackOverflow, please see it for full detail of how the models are laid out: http://stackoverflow.com/questions/36463623/optimally-access-an-sqlalchemy-model-paramater-n-number-of-relationships-away I have

Re: [sqlalchemy] back_populates doesn't work properly on one-to-one relationships (uselist=False)

2016-03-19 Thread Mike Bayer
On 03/17/2016 09:15 PM, univerio wrote: Consider these models: class Foo(Base): __tablename__ = 'foo' id = Column(Integer, primary_key=True, autoincrement=True) bar_id = Column(Integer, ForeignKey("bar.id"), unique=True) bar = relationship(lambda: Bar,

Re: [sqlalchemy] Backref primary join condition stopped working in 0.9.4

2016-03-19 Thread Mike Bayer
metadata.create_all(e) s = Session(e) *c1, c2, c3 = C(), C(), C() c0 = C(children=[c1, c2, c3])* s.add(c0) s.commit() *c2._del = 1 *s.commit() *assert c0.children == [c1, c3]* On Wed, Mar 16, 2016 at 12:42 PM, Mike Bayer <clas...@zzzcomputing.com <mailto:clas...@zzzcomputing.com>

Re: [sqlalchemy] OperationalError with SQLite with simple update query

2016-03-19 Thread Mike Bayer
On 03/16/2016 11:23 AM, Piotr Dobrogost wrote: so TextValue and Node should be implicitly joined according to rules for joined table polymorphism in SA. this is not supported - please read the caveats at

Re: [sqlalchemy] Number of Open ConnectionPool connections

2016-03-19 Thread Mike Bayer
The most exact way to determine how many database connections a Python process is using is to use netstat. If you need a quick number and don't care about internals, that's your number. Next, if you're in the Python process and have specific pool / engine to look at, it can give you an

Re: [sqlalchemy] Re: rowset generating functions in FROM clause

2016-03-22 Thread Mike Bayer
On 03/22/2016 05:37 AM, Andy S wrote: I'm stuck with the need to generate a query of the form like: | SELECT a.id, b.name, jr.* FROM a,b outer join jsonb_populate_recordset(b.jrs)asjr(bid numeric,name varchar)on (TRUE) WHERE a.id =b.a_id

Re: [sqlalchemy] bug with func.lower in bindparam?

2016-03-25 Thread Mike Bayer
On 03/25/2016 09:48 AM, Brian Cherinka wrote: Hi, Is there perhaps a bug in the sqlalchemy function lower (func.lower)? I'm trying to do a simple query that filters on a string keyword (the label of a header_keyword). I want to bind the parameter so I can easily update the label after the

Re: [sqlalchemy] can't generate a correlated update without an anonymous alias

2016-03-25 Thread Mike Bayer
On 03/25/2016 12:23 PM, Jonathan Vanasco wrote: I created a testcase here - https://gist.github.com/jvanasco/a2ff04614a23e192ac7f this has been stumping me this morning. the sql I want is: update table_a set id_b__latest = ( :other_query ) generated from something like:

Re: [sqlalchemy] rowset generating functions in FROM clause

2016-03-21 Thread Mike Bayer
for the "postgresql JSON function that wants to be in the FROM clause", there is a way to do this with plain Core API but it generates a subquery (that's here: http://docs.sqlalchemy.org/en/rel_1_0/core/tutorial.html#functions , scroll down a little in that section), but also I've been

Re: [sqlalchemy] Modeling single FK to multiple tables

2016-03-25 Thread Mike Bayer
ing. I can paste the full code if you want, but it's pretty long. On 3/17/16, Mike Bayer <clas...@zzzcomputing.com> wrote: On 03/17/2016 03:11 PM, Alex Hall wrote: Hello all, It seems like I can't go a day without running into some kind of wall. This one is a conceptual one regarding fore

Re: [sqlalchemy] SQLALchemy session.merge is not working as expected

2016-03-26 Thread Mike Bayer
lf.type =type self.created_at =created_at self.updated_at =updated_at| El sábado, 26 de marzo de 2016, 17:26:04 (UTC+1), Mike Bayer escribió: On 03/26/2016 12:06 PM, Ricardo Champa wrote: > AFAIK merge performs and |insert or update| so what I'm doing is pretty > simp

Re: [sqlalchemy] SQLALchemy session.merge is not working as expected

2016-03-27 Thread Mike Bayer
s much as i can. I did another simple sample of code wihtout columns and relationships (adding and removing) and seems working fine. There is an error with my code above but I cant figure out what. El sábado, 26 de marzo de 2016, 18:05:23 (UTC+1), Mike Bayer escribió: On 03/26/2016

Re: [sqlalchemy] Backref primary join condition stopped working in 0.9.4

2016-03-19 Thread Mike Bayer
On 03/16/2016 02:37 PM, Thorsten von Stein wrote: For several years, I have been using a pattern for making a many-to-one relationship from *cls* to *remoteCls* with a one-to-many backref with a join condition cls.foreignKey == remoteCls.id, where *cls* has a deletion flag _del which should

Re: [sqlalchemy] Cannot generate sql for shared mode lock (`LOCK IN SHARE MODE`)

2016-03-19 Thread Mike Bayer
dialect specific: from sqlalchemy.dialects import mysql print SomeClass.__table__.select(SomeClass.id == 1).with_for_update(read=True).compile(dialect=mysql.dialect()) SELECT some_table.id, some_table.name FROM some_table WHERE some_table.id = %s LOCK IN SHARE MODE

Re: [sqlalchemy] SQLALchemy session.merge is not working as expected

2016-03-26 Thread Mike Bayer
On 03/26/2016 12:06 PM, Ricardo Champa wrote: AFAIK merge performs and |insert or update| so what I'm doing is pretty simple. There is a relation of 1 to N between Hubs and Tags. So when I try to make a merge on tag and hub, hub goes well and load from DB the existent hub and make an update,

Re: [sqlalchemy] How can I use negate for operator in UserDefinedType.Comparator

2016-03-08 Thread Mike Bayer
and documented better.most "custom ops" are not boolean operators that have a "negation"; also if you leave out the "negate" thing here you'd just get "NOT (col ~ expr)" which is just as good? On Mon, 7 Mar 2016, at 22:42, Mike Bayer wrote: On 03/07

Re: [sqlalchemy] mssql: UnicodeDecodeError: 'utf8' codec can't decode byte

2016-03-06 Thread Mike Bayer
Can you share a stack trace please ? Encoding operations can occur in many places and I don't see that identified here. Also this is Python 3? What OS platform and ODBC driver / configuration as well? If freetds please share your freetds config too. > On Mar 4, 2016, at 2:51 PM, Tim

Re: [sqlalchemy] replacing a filter attribute, or iterating over a booleanclauselist?

2016-03-02 Thread Mike Bayer
On 03/02/2016 03:29 PM, Brian Cherinka wrote: Hi, After a query has been constructed with some filter conditions applied, but before the query has been run, what's the best way to replace the attribute in the filter clause? Let's say I have a query like this | q

Re: [sqlalchemy] replacing a filter attribute, or iterating over a booleanclauselist?

2016-03-02 Thread Mike Bayer
in : q = q.filter_by(name = bindparam(name)) though I'd think if you're dynamically building the query you'd have the values already, not sure how it's working out that you need bindparam() at that stage... Cheers, Brian On Wednesday, March 2, 2016 at 4:28:46 PM UTC-5, Mike Bayer wrote

Re: [sqlalchemy] Re: Assertion error on deleting one end of many-to-many relation

2016-03-03 Thread Mike Bayer
On 03/03/2016 07:36 AM, Lele Gaifax wrote: Simon King writes: In general I think it is not recommended to use "secondary" with a table that you have also mapped a class to. (eg. see the warning at the bottom of

Re: [sqlalchemy] How can I use negate for operator in UserDefinedType.Comparator

2016-03-07 Thread Mike Bayer
On 03/07/2016 09:11 AM, Frazer McLean wrote: ||I am trying to add regexp and iregexp operators to a subclass of the Text type. I'm using SQLAlchemy v1.0.12. I am able to correctly use '~' and '!~' operators if I use a notregexp method like this: | importsqlalchemy.types astypes

Re: [sqlalchemy] How can I use negate for operator in UserDefinedType.Comparator

2016-03-07 Thread Mike Bayer
against=operator) AttributeError: 'str' object has no attribute 'self_group' """ | Thanks! On Monday, 7 March 2016 18:36:11 UTC+1, Mike Bayer wrote: On 03/07/2016 09:11 AM, Frazer McLean wrote: > ||I am trying to add regexp and iregexp operators to a subclass of

Re: [sqlalchemy] Core API and Polymorphic Identity: a possible bug

2016-03-08 Thread Mike Bayer
On 03/08/2016 12:50 PM, adrianodilu...@gmail.com wrote: I've spotted the following strange behaviour while using the last version (SQLAlchemy==1.0.12) with SQLite or PostgreSQL (possibly others, too). To be short, I created a few polymorphic classes that map to their respective tables; I'm

Re: [sqlalchemy] extract the WEEK off a timestamp across multiple database backends

2016-04-03 Thread Mike Bayer
On 04/02/2016 05:12 PM, Jonathan Vanasco wrote: I need to extract the week of the year across multiple databases (this needs to work on at-least sqlite and postgres, though mysql would be good too.) the problem? this operation isn't standard: sqlite: select strftime('%W',

Re: [sqlalchemy] trouble with advanced orm relationship (primary + secondary)

2016-04-04 Thread Mike Bayer
On 04/04/2016 07:35 PM, Jonathan Vanasco wrote: I've been battling with a particular relationship and eventually managed to get it working based off the docs when I realized I had a similar way to short-circuit the chain, however I'm not happy with the result.

Re: [sqlalchemy] information schema with sqlalchemy and pymssql reflection and case sensitivity issue

2016-04-04 Thread Mike Bayer
On 04/04/2016 06:10 PM, Douglas Eisenstein wrote: Hi, Here's the situation, we're trying to reflect tables from SQL Server into metadata, and we're encountering a problem of case sensitivity, in particular when it executes the following query: SELECT [C].[COLUMN_NAME], [R].[TABLE_SCHEMA],

Re: [sqlalchemy] scoped_session, sessions and thread safety

2016-03-31 Thread Mike Bayer
a context manager any more than if you did so inside of an "if:" statement This would allow me to solve problem #1 because I can create as many independant sessions as i want within the same thread and commit them when i want to. Le mercredi 30 mars 2016 19:00:16 UTC+2, Mike Bay

Re: [sqlalchemy] `func.similarity` performance

2016-03-31 Thread Mike Bayer
On 03/30/2016 09:50 PM, Robert Smith wrote: I'm using sqlalchemy 1.0.12 with postgreSQL 9.4.6 with the pg_trgm extension enabled. Basically, I'm performing a similarity-based query on a single column: In [26]: str(session.query(Model).order_by(desc(func.similarity(Model.description,

Re: [sqlalchemy] scoped_session, sessions and thread safety

2016-03-31 Thread Mike Bayer
On 03/31/2016 10:38 AM, Mehdi GMIRA wrote: > > 1) One limitation that i find to the scoped_session is that you're > limited to exactly one session by thread. that's not true at all, make as many sessions as you want from the sessionmaker() inside of it (or just use

Re: [sqlalchemy] `func.similarity` performance

2016-03-31 Thread Mike Bayer
On 03/31/2016 06:40 PM, Robert Smith wrote: Mike Bayer: Thank you for your response. I wasn't really asking whether the optimization I described above (using `%` instead of `similarity`) is correct or not. Based on some resources (e.g. Super Fuzzy Searching on PostgreSQL <h

Re: [sqlalchemy] Modeling single FK to multiple tables

2016-03-28 Thread Mike Bayer
the time I was spending with SA)? On 3/25/16, Mike Bayer <clas...@zzzcomputing.com> wrote: On 03/25/2016 05:20 PM, Alex Hall wrote: Hi all, Since SA was proving to be difficult to get working, and I was spending way more time just trying to get it working than I was actually running q

Re: [sqlalchemy] Executing callback after current transaction commit unless rollback occurs

2016-03-29 Thread Mike Bayer
called") @event.listens_for(sess, "after_transaction_end") def bar(session, transaction): print('after_transaction_end') session.info["my_token"] = True sess.add(User(id=3)) sess.commit() sess.add(User(id=2)) sess.commit() On Tuesday, March 29, 2016 at 1:41:32 AM UTC+3, Mi

Re: [sqlalchemy] relationships, potentially large collections and eagerloading/bad dbs.

2016-03-29 Thread Mike Bayer
On 03/29/2016 06:32 PM, Jonathan Vanasco wrote: I'm in the processes of open-sourcing a mini-project and need to support sqlite -- so I'd like to be a bit easier on DB operations. The following use-case is puzzling me: I want to view a record on TableA, which will show the last 5 related

Re: [sqlalchemy] SQLAlchemy 1.0.12 use inner JOIN instead of LEFT OUTER JOIN

2016-04-25 Thread Mike Bayer
On 04/25/2016 05:16 PM, Alex Dev wrote: Hello, I have a broken query when migrating from SQLAlchemy 0.9.4 to 1.0.12. It seems to be linked to a behavioral change in the ORM

Re: [sqlalchemy] Bug in BufferedColumnResultProxy class?

2016-04-25 Thread Mike Bayer
On 04/25/2016 11:04 AM, Piotr Dobrogost wrote: On Mon, Apr 25, 2016 at 3:23 PM, Mike Bayer <mike...@zzzcomputing.com> wrote: OK I can try to work with that but that's a very specific feature, you'd need to be using the Query cache extension, I have problem finding information on

Re: [sqlalchemy] Declaring column NOT NULL only for specific dialect (Oracle)?

2016-04-22 Thread Mike Bayer
On 04/22/2016 11:51 AM, Piotr Dobrogost wrote: >On Friday, April 22, 2016 at 5:02:17 PM UTC+2, Mike Bayer wrote: > >For this one, assuming you're using metadata.create_all() and not an >alembic migration, the CreateColumn DDL construct gives you a hook for >this kind of

Re: [sqlalchemy] Bug in BufferedColumnResultProxy class?

2016-04-27 Thread Mike Bayer
On 04/27/2016 11:11 AM, Mike Bayer wrote: I'm improving our test suite by ensuring that result processors are fired off for all result proxy subtypes when caching is used as well and I will ensure the line of code you mention is exercised. If I can reproduce your described issue

Re: [sqlalchemy] 0.8 - `q.filter(None)` used to do nothing, now generates "WHERE NULL"

2016-04-27 Thread Mike Bayer
On 04/27/2016 01:09 PM, kevinlon...@chownow.com wrote: It would be helpful if this change was included in the changelog. We were upgrading from an old version of SQLAlchemy that used this to do things like: .filter(MyClass.attribute > value if value else None) And we had some queries

Re: [sqlalchemy] Bug in BufferedColumnResultProxy class?

2016-04-27 Thread Mike Bayer
On 04/26/2016 12:11 PM, Piotr Dobrogost wrote: On Tue, Apr 26, 2016 at 12:18 AM, Mike Bayer <mike...@zzzcomputing.com> wrote: On 04/25/2016 11:04 AM, Piotr Dobrogost wrote: Is caching using dogpile what you call "Query cache extension"? If so we don't use it. this

Re: [sqlalchemy] relationship joined to max() on a foreign table - help needed

2016-04-26 Thread Mike Bayer
On 04/26/2016 08:09 AM, Rob Fowler wrote: I have a complete example here: https://gist.github.com/mianos/42cf15928f27cc9dfde9996d2e593e78 Ideas? I am sure it's possible. At the moment I am just using a "orderby desc" on the relationship and using [0] to get the first. this example helps

Re: [sqlalchemy] Declaring column NOT NULL only for specific dialect (Oracle)?

2016-04-26 Thread Mike Bayer
On 04/26/2016 06:27 AM, Piotr Dobrogost wrote: Do I see right, that using @compiles(schema.CreateColumn, 'oracle') is not good as it's being invoked too late to have access to colspec? It seems I have to override DDLCompiler.get_column_specification() and then I have to copy & paste code

Re: [sqlalchemy] Trying to create string array columns with Alembic gives "NameError: name 'String' is not defined"

2016-04-26 Thread Mike Bayer
On 04/26/2016 10:07 AM, Simon King wrote: Can you show us the contents of alembic/versions/dd9e391f807f_issues_is_behind.py ? just a heads up this user is likely hitting https://bitbucket.org/zzzeek/alembic/issues/85/using-postgresqlarray-unicode-breaks, where the "sa." prefix is missing

Re: [sqlalchemy] Declaring column NOT NULL only for specific dialect (Oracle)?

2016-04-26 Thread Mike Bayer
On 04/26/2016 11:19 AM, Piotr Dobrogost wrote: Questions I asked in my last post are concerned more with implementing IDENTITY for Oracle. Here the situation is not so simple and simply replacing text is not possible as "GENERATE AS IDENTITY" phrase must be placed in right order with regard to

Re: [sqlalchemy] Bug in BufferedColumnResultProxy class?

2016-04-25 Thread Mike Bayer
On 04/25/2016 05:49 AM, Piotr Dobrogost wrote: On Friday, April 22, 2016 at 5:22:38 PM UTC+2, Mike Bayer wrote: On 04/22/2016 10:40 AM, Piotr Dobrogost wrote: > It seems BufferedColumnResultProxy class (used only in Oracle dialect) > has a bug. I cannot c

Re: [sqlalchemy] Changing columns in query

2016-04-30 Thread Mike Bayer
yes please use query.with_entities http://docs.sqlalchemy.org/en/rel_1_0/orm/query.html?highlight=query.with_entities#sqlalchemy.orm.query.Query.with_entities On 04/30/2016 02:33 AM, Антонио Антуан wrote: I have the query: | q =Session.query(func.array_agg(Order.col)) | The compiled query

Re: [sqlalchemy] Is there a good doc page/tutorial for writing a dialect?

2016-05-19 Thread Mike Bayer
the guidelines we have are in a README you can see here: https://github.com/zzzeek/sqlalchemy/blob/master/README.dialects.rst however, the best way to really get into the methods and things is to look at the existing dialects and see what they are doing.we don't have extensive

Re: [sqlalchemy] Dialect not replacing ? with parameter

2016-05-19 Thread Mike Bayer
a SQL query that uses parameters will use ? if the DBAPI uses "qmark" paramstyle which is very common. The actual value that lines up with the ? is part of the "parameters" sequence. The specification for this is at https://www.python.org/dev/peps/pep-0249/#id15 which also links out to

Re: [sqlalchemy] Re: SQLAlchemy 1.0.13 released

2016-05-17 Thread Mike Bayer
well now that I'm self-hosting I would maybe need to consider that, though the aggregate number of web hits is not that unmanageable. It's not the delivery of the HTML that's been the problem, it's running the sphinx "make html" that fails on RTD due to memory / time limits. On 05/17/2016

Re: [sqlalchemy] zero_indexes broken for 2d-arrays?

2016-05-23 Thread Mike Bayer
On 05/23/2016 10:12 AM, Brian Cherinka wrote: Hi, It seems like the ARRAY option zero_indexes=True is broken for 2-dimensional arrays. Is this a bug that is fixed in 1.1? I'm actually using the subclass ARRAY_D as a fix for the __getitem__ indexing. It works for 1-D arrays. if you're

Re: [sqlalchemy] Create Table DDL options before "("

2016-05-23 Thread Mike Bayer
ek/sqlalchemy/pull/275> and in gerrit <https://gerrit.sqlalchemy.org/#/c/85/1> (which I'm still getting used too). On Sunday, May 22, 2016 at 8:23:14 PM UTC-7, Mike Bayer wrote: OK so we'll probably just add the hook you've proposed. I've not had anytime to work on a compu

Re: [sqlalchemy] Using SQL_CALC_FOUND_ROWS

2016-05-23 Thread Mike Bayer
I answered this for someone some time ago, assuming FOUND_ROWS() is local to a MySQL session (note this is not the same thing as a SQLAlchemy session though typically these map in a 1-1 fashion) there should be no issue, as long as you are using each connection in just one application thread

Re: [sqlalchemy] How to map class to multiple tables (for sharding purpose)

2016-05-19 Thread Mike Bayer
On 05/19/2016 08:58 AM, Михаил Доронин wrote: Suppose I have models (with corresponding tables) in pseudocode table1 | some_unique_name | some_property | |--+---| | foo | 1 | |--+---| | bar | 2

Re: [sqlalchemy] Create Table DDL options before "("

2016-05-19 Thread Mike Bayer
saw your pull request, just curious what database / DDL is this? Just like to see the finished product that you're going for. On 05/18/2016 09:19 PM, Mark Sandan wrote: Hi, I'm implementing a dialect for sqlalchemy and would like to add options before the '(' but after the table name in

Re: [sqlalchemy] Create Table DDL options before "("

2016-05-22 Thread Mike Bayer
KRATIO ( c1 VARCHAR(128) NOT NULL, Id BYTE(4) NOT NULL, OwnerId BYTE(4) NOT NULL ) UNIQUE PRIMARY INDEX ( c1 ) UNIQUE INDEX ( Id ); | On Thursday, May 19, 2016 at 8:31:49 AM UTC-7, Mike Bayer wrote: saw your pull request, just curious what database

Re: [sqlalchemy] Calculated relationships

2016-05-22 Thread Mike Bayer
On 05/21/2016 02:06 PM, Jonathan Vanasco wrote: On Saturday, May 21, 2016 at 12:30:26 PM UTC-4, Andrew Pashkin wrote: It's strange, why I don't see the first post in the thread? this has happened a few times this week. any chance this is from a moderation feature, mike? Google

<    4   5   6   7   8   9   10   11   12   13   >