Re: [sqlalchemy] How to use BLOB datatype in alembic tool to support Postgresql?

2012-10-30 Thread Mike Bayer
take a look at LargeBinary: http://docs.sqlalchemy.org/en/rel_0_7/core/types.html#sqlalchemy.types.LargeBinary On Oct 30, 2012, at 2:27 PM, junepeach wrote: We want to support as many databases as we can. Right now we have BLOB data type defined in our database schemas, both sqlite3 and

Re: [sqlalchemy] Using Alembic to maintain versions of SPs and other objects?

2012-10-30 Thread Mike Bayer
On Oct 30, 2012, at 2:39 PM, Don Dwiggins wrote: It appears that, at least currently, Alembic only directly manages tables (although I guess one could include SQL code in the upgrade/downgrade functions to add/delete/change SPs, user defined types, functions, etc. Am I right in this? If

Re: [sqlalchemy] Sub-classing declarative classes

2014-06-10 Thread Mike Bayer
On Tue Jun 10 15:47:00 2014, Noah Davis wrote: some_model.py --- [SQLA setup of Base class here] class Alice(Base): __tablename__ = 'alice' id = Column(Integer, primary_key=True) value = Column(String) class Bob(Base): __tablename__ = 'bob'

Re: [sqlalchemy] another quick question regarding abstract classes

2014-06-10 Thread Mike Bayer
On Tue Jun 10 15:36:09 2014, Richard Gerd Kuesters wrote: so, here i am again with another weird question, but it may be interesting for what it may come (i dunno yet). the problem: i have a collection of abstract classes that, when requested, the function (that does the request) checks in a

Re: [sqlalchemy] how to tell if a relationship was loaded or not ?

2014-06-11 Thread Mike Bayer
On 6/11/14, 2:17 PM, Jonathan Vanasco wrote: I can't find this in the API or by using `inspect` on an object. I'm trying to find out how to tell if a particular relationship was loaded or not. ie, I loaded Foo from the ORM, and want to see if foo.bar was loaded. I thought it might have

Re: [sqlalchemy] pandas - issue with SQL server and checking for table existence with user-defined default schema

2014-06-11 Thread Mike Bayer
On 6/11/14, 4:07 PM, Joris Van den Bossche wrote: Hi, Since version 0.14 (released two weeks ago), pandas uses sqlalchemy in the SQL reading and writing functions to support different database flavors. A user reported an issue with SQL server: https://github.com/pydata/pandas/issues/7422

Re: [sqlalchemy] uwsgi + sqlalchemy - forking concern

2014-06-15 Thread Mike Bayer
yeah what he said, but also, in a forking situation the easiest thing you can do is, as soon as the fork starts, say engine.dispose(). Or just engine = some new engine. all you need to do is make sure no DB connections in the pool (or anywhere else) are allowed to continue in the fork. On

Re: [sqlalchemy] Intermittent error when retrieving an attribute of a persistent object

2014-06-16 Thread Mike Bayer
it's unlikely we can do much about that, jython is hardly used at all and is not a well-maintained platform; it regularly has subtle interpreter bugs and such. pg8000 is in better shape these days but tracking down something like this would require careful pdb debugging and tracing. That

Re: [sqlalchemy] column ordering with union_all and joinedload?

2014-06-16 Thread Mike Bayer
SQLAlchemy targets mapped entities in a result set by their position within the Query object's entities. It's not possible to have a UNION that returns some objects of type A and then some objects of type B in the same position, unless those two classes are related through polymorphic

Re: [sqlalchemy] Is there a reason why there is no dialect specific fix for ORA-01795?

2014-06-17 Thread Mike Bayer
On 6/17/14, 4:32 AM, Ofir Herzas wrote: ORA-01795: maximum number of expressions in a list is 1000 As I understand, there are several options to fix this issue (e.g. https://groups.google.com/forum/#!searchin/sqlalchemy/maximum$20number$20of$20expressions/sqlalchemy/Oa6YWNE0-IQ/6GVmy27B-FAJ

Re: [sqlalchemy] Is there a reason why there is no dialect specific fix for ORA-01795?

2014-06-17 Thread Mike Bayer
On 6/17/14, 9:30 AM, Ofir Herzas wrote: This can be done only for Oracle and only if the number of expressions is higher than 1000 (which would otherwise produce an exception) Regarding complex queries, I guess the several or_'s fix should work: or_(x.in_(1...1000), x.in_(1001...2000)) How

Re: [sqlalchemy] Re: FAQ for CREATE TABLE output incomplete

2014-06-18 Thread Mike Bayer
On 6/18/14, 2:06 AM, rpkelly wrote: It seems like passing literal_binds=True to the call to sql_compiler.process in get_column_default_string will work, so long as SQLAlchemy can convert the values to literal binds. Which, in the example given, isn't the case. the long standing practice for

Re: [sqlalchemy] Re: FAQ for CREATE TABLE output incomplete

2014-06-18 Thread Mike Bayer
On 6/18/14, 12:03 PM, Ryan Kelly wrote: On Wed, Jun 18, 2014 at 11:15 AM, Mike Bayer mike...@zzzcomputing.com wrote: On 6/18/14, 2:06 AM, rpkelly wrote: It seems like passing literal_binds=True to the call to sql_compiler.process in get_column_default_string will work, so long as SQLAlchemy

Re: [sqlalchemy] Functions on column properties

2014-06-18 Thread Mike Bayer
On 6/18/14, 4:50 PM, Mike Solomon wrote: Le mercredi 18 juin 2014 22:03:33 UTC+3, Michael Bayer a écrit : if you can show the SQL you expect that would help. it seems in your SO question you want a subquery, you'd have to define that: class Holder(..): some_prop =

Re: [sqlalchemy] How to have SQL IF in sqlalchemy

2014-06-18 Thread Mike Bayer
On 6/18/14, 8:31 PM, Vineet Goel wrote: Hi, I am trying to convert the following SQL to SQLAlchemy: |SELECT teams.department, teams.team, IF(employee_managers.team_id IS NOT NULL, employee_managers.manager, teams.default_manager) AS manager FROM teams LEFT JOIN employee_managers

Re: [sqlalchemy] Functions on column properties

2014-06-19 Thread Mike Bayer
On 6/19/14, 4:09 AM, Mike Solomon wrote: It's difficult to issue a straight SQL string for the hybrid property itself because sorry, I meant, please write the query *that you really want* as a SQL string. Don't use SQLAlchemy. It's better to work in that direction. If you don't know

Re: [sqlalchemy] hybrid_properties and literals

2014-06-19 Thread Mike Bayer
On 6/19/14, 1:05 PM, AM wrote: What I am storing is things like string versions of lists, tuples and dicts, for e.g.: str([1, 2, 3]) str({'a':1} and so on. ast.literal_eval will only parse those and return those, it does not evaluate expressions and statements so no real code at all. I

Re: [sqlalchemy] unable to open database file

2014-06-19 Thread Mike Bayer
no but this is more of a pysqlite/sqlite3 issue, you should ask on the Python users list, and refer to the sqlite3.connect() function: import sqlite3 conn = sqlite3.connect(/path/to/file.db) On 6/19/14, 2:28 PM, Scott Horowitz wrote: Hi, A user of my applicable is getting a unable to open

Re: [sqlalchemy] Functions on column properties

2014-06-19 Thread Mike Bayer
On 6/19/14, 2:41 PM, Mike Solomon wrote: Le jeudi 19 juin 2014 16:10:19 UTC+3, Michael Bayer a écrit : On 6/19/14, 4:09 AM, Mike Solomon wrote: It's difficult to issue a straight SQL string for the hybrid property itself because sorry, I meant,

Re: [sqlalchemy] unable to open database file

2014-06-19 Thread Mike Bayer
On 6/19/14, 3:37 PM, Scott Horowitz wrote: Michael, Thanks for the hint about python's sqlite3. I'll just point out that I can work around the issue directly with sqlite3 by providing a relative path that does not include the character: import sqlite3, os

Re: [sqlalchemy] correlating related deletes

2014-06-19 Thread Mike Bayer
On 6/19/14, 8:02 PM, Jonathan Vanasco wrote: Due to a business requirement and an odd distribution of data / performance issue, my database currently has 2 tables which are inter-related : class Relationship(): id_a = int ,references table_a(id) id_b = int, references

Re: [sqlalchemy] Could not locate column in row for column

2014-06-20 Thread Mike Bayer
On 6/20/14, 3:59 AM, Belegnar Dragon wrote: Hello. SQLAlchemy 0.9.4 In this code def unidecode_column_name(inspector, table, column_info): column_info['key'] = unidecode(column_info['name']).replace(u' ', u'_') engine = create_engine(mssql+pyodbc://%s:%s@RTBD % (settings.RT_USER,

Re: [sqlalchemy] Could not locate column in row for column

2014-06-20 Thread Mike Bayer
On 6/20/14, 7:32 AM, Mike Bayer wrote: NoSuchColumnError: Could not locate column in row for column '\\u0417\\u0430\\u043a\\u0430\\u0437\\u044b.\\u041d\\u043e\\u043c\\u0435\\u0440 \\u0437\\u0430\\u043a\\u0430\\u0437\\u0430' The problem is i can't really debug this error because it isn't

Re: [sqlalchemy] Could not locate column in row for column

2014-06-20 Thread Mike Bayer
On 6/20/14, 12:14 PM, Mike Bayer wrote: On 6/20/14, 7:32 AM, Mike Bayer wrote: NoSuchColumnError: Could not locate column in row for column '\\u0417\\u0430\\u043a\\u0430\\u0437\\u044b.\\u041d\\u043e\\u043c\\u0435\\u0440 \\u0437\\u0430\\u043a\\u0430\\u0437\\u0430' The problem is i can't

Re: [sqlalchemy] A question regarding hybrid properties, relationships and schema changes

2014-06-20 Thread Mike Bayer
On 6/20/14, 3:38 PM, Ken Lareau wrote: So in the ongoing improvement of one of our internal databases, we created a new table named 'environments' whose SQLA code looks something like this: class Environment(Base): __tablename__ = 'environments' id = Column(u'environmentID',

Re: [sqlalchemy] getting error with column name end using geoalchemy2

2014-06-21 Thread Mike Bayer
On 6/21/14, 8:34 AM, Chung WONG wrote: Hi list, I am encountering a very strange error and I am scratching my head and got no idea what is going on. class Line(Base): __tablename__ = 'lines' id = Column(Integer, Sequence('line_id_seq'), primary_key=True) start =

Re: [sqlalchemy] Is using column_property preferred over hybrid property in some circumstances?

2014-06-21 Thread Mike Bayer
On 6/21/14, 4:00 PM, Bao Niu wrote: The documentation regarding column_property and hybrid property says both methods are intended for linking a sql expression to an attribute, which is highly useful. But it is not obvious to junior users which one is preferred. Heh.Well, one is much

[sqlalchemy] SQLAlchemy 0.9.5 Released

2014-06-23 Thread Mike Bayer
Hey list - SQLAlchemy release 0.9.5 is now available. 0.9.5 contains mostly bug fixes as well as some smaller enhancements, and the first to be alongside new features and refactorings going into the 1.0 release branch.While the issue queue still has a handful of critical fixes to go, it's

Re: [sqlalchemy] Postgresql 9.4 JSONB support

2014-06-24 Thread Mike Bayer
On 6/24/14, 3:32 AM, Damian Dimmich wrote: Hello, I've started putting together support for JSONB - a new type introduced with the postgres 9.4 beta here: https://github.com/ddimmich/sqlalchemy As this shares a lot with the JSON datatype I've kept the code in the json.py file. Please

Re: [sqlalchemy] A question regarding hybrid properties, relationships and schema changes

2014-06-24 Thread Mike Bayer
On 6/23/14, 8:09 PM, Ken Lareau wrote: if apptier: subq = ( Session.query( Package.pkg_name, Package.version, Package.revision, AppDefinition.app_type, AppDeployment.environment

Re: [sqlalchemy] inheriting from mapped classes

2014-06-24 Thread Mike Bayer
On 6/24/14, 5:44 PM, Victor Olex wrote: So, what is the right idiom for building SQLAlchemy persistence into classes that need to do more than just that i.e. have run-time state. I was hoping that deriving from SQLAlchemy model classes, but that does not seem to be it. Another option would be

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

2014-06-25 Thread Mike Bayer
On 6/25/14, 5:50 AM, Ofir Herzas wrote: Sorry to barge in, but I'm having the exact same issue and I'm pretty sure no one altered the sequence manually. I'm using sqlalchemy 0.8, python 2.7.6, rhel 6.5, oracle 10g, cx_oracle with the same connection string as above This issue started just

Re: [sqlalchemy] Treating many-to-many relationships as many-to-one

2014-06-25 Thread Mike Bayer
On 6/25/14, 7:11 AM, Tara Andrews wrote: Hello, I am trying to use SQLAlchemy to map a database that was made available to me, whose contents and schema cannot be altered. The database has a few cases where a many-to-one relationship is treated as a many-to-many - that is, instead of the

Re: [sqlalchemy] A question regarding hybrid properties, relationships and schema changes

2014-06-25 Thread Mike Bayer
On 6/25/14, 2:26 AM, Ken Lareau wrote: On Tue, Jun 24, 2014 at 3:35 PM, Mike Bayer mike...@zzzcomputing.com mailto:mike...@zzzcomputing.com wrote: On 6/23/14, 8:09 PM, Ken Lareau wrote: if apptier: subq = ( Session.query

Re: [sqlalchemy] postgresql large objects

2014-06-25 Thread Mike Bayer
On 6/25/14, 2:35 AM, Jason Newton wrote: Hi, I'm wondering how I might get at postgresql's large object type (lob). It's not to be confused with the TOASTED bytea, which are limited currently to 1 GiB yet in practice is much lower (for me 400MiB) - it's a special table + api designed to

Re: [sqlalchemy] postgresql large objects

2014-06-25 Thread Mike Bayer
On 6/25/14, 2:53 PM, Jason Newton wrote: Seems to fly in the face at the point of SQLA although integration difficulties are appreciated. Most advanced postgresql drivers in any language bindings have added support for this type although none of them can hide that it's file like. SQLA

Re: [sqlalchemy] postgresql large objects

2014-06-25 Thread Mike Bayer
On 6/25/14, 5:35 PM, Jason Newton wrote: Hand crafted inserts use server side lo_create(-1) (in sql) which allocates a new large object and returning clause to get the oid in one go back to the client side. Then I start using the lobject api on the returned oid.

Re: [sqlalchemy] Joins across differently-sharded tables

2014-06-25 Thread Mike Bayer
On 6/25/14, 6:36 PM, Neil Hooey wrote: Is it possible to do a join query on two tables that have different shard keys in SQLAlchemy? For example, if you have two tables: users: [userId, name] (sharded on userId) messages: [messageId, userId, message] (sharded on messageId) Could you

Re: [sqlalchemy] Aggregate functions across shards

2014-06-25 Thread Mike Bayer
On 6/25/14, 6:41 PM, Neil Hooey wrote: Do aggregate functions work across shards in SQLAlchemy? Such as count, sum, etc? not across them, nope. you need to merge those yourself. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To unsubscribe

Re: [sqlalchemy] Performance problem of simple orm usage

2014-06-26 Thread Mike Bayer
On 6/26/14, 11:49 AM, Hans-Peter Jansen wrote: Dear SQLAchemistas, I'm suffering from a performance problem from a simple sequence like this: rec is a sensor record coming redundantly from the network, enos is a sensor device, ev is a sensor value record: def store_enos_rec(self,

Re: [sqlalchemy] AssertionError: Type class 'sqlalchemy.engine.interfaces.Connectable' is already registered

2014-06-26 Thread Mike Bayer
that looks pretty much like modules are being reloaded in process. Either get web.py to not reload the sqlalchemy modules, or if it has to, then get it to fully load sqlalchemy completely. I see that reload(mod) right in the stack trace there. On 6/26/14, 1:14 PM, Dustin Oprea wrote: I'm

Re: [sqlalchemy] Performance problem of simple orm usage

2014-06-26 Thread Mike Bayer
On 6/26/14, 12:24 PM, Mike Bayer wrote: I'm not sure what kind of application this is but I would not be mixing transactional control, that is the commit/rollback, inside of a business method that only seeks to create some new objects. There'd be a containing pattern within which

Re: [sqlalchemy] AssertionError: Type class 'sqlalchemy.engine.interfaces.Connectable' is already registered

2014-06-26 Thread Mike Bayer
On 6/26/14, 1:49 PM, Dustin Oprea wrote: On Jun 26, 2014 1:34 PM, Mike Bayer mike...@zzzcomputing.com mailto:mike...@zzzcomputing.com wrote: that looks pretty much like modules are being reloaded in process.Either get web.py to not reload the sqlalchemy modules, or if it has

Re: [sqlalchemy] Performance problem of simple orm usage

2014-06-26 Thread Mike Bayer
On 6/26/14, 3:07 PM, Hans-Peter Jansen wrote: Okay, attached is a profile dump with .commit() out of the way. Here's the head of it: -- p = pstats.Stats('srelay.pstats') -- p.strip_dirs().sort_stats('cumulative').print_stats(100) Thu Jun 26 20:41:50 2014 srelay.pstats 55993702 function calls

Re: [sqlalchemy] A question regarding hybrid properties, relationships and schema changes

2014-06-26 Thread Mike Bayer
minimal mapping + the query against that mapping. On 6/26/14, 4:11 PM, Ken Lareau wrote: On Thu, Jun 26, 2014 at 5:57 AM, Mike Bayer mike...@zzzcomputing.com mailto:mike...@zzzcomputing.com wrote: On 6/25/14, 8:06 PM, Ken Lareau wrote: On Wed, Jun 25, 2014 at 6:28 AM, Mike Bayer

Re: [sqlalchemy] Performance problem of simple orm usage

2014-06-26 Thread Mike Bayer
On 6/26/14, 5:18 PM, Hans-Peter Jansen wrote: Dear Mike, sorry for not coping with preferred reply behavior.. On Donnerstag, 26. Juni 2014 15:26:02 Mike Bayer wrote: On 6/26/14, 3:07 PM, Hans-Peter Jansen wrote: Obviously, some operation triggers the flush method with about the same

Re: [sqlalchemy] A question regarding hybrid properties, relationships and schema changes

2014-06-26 Thread Mike Bayer
(t_ordered.realized) unix_timestamp(now()) - :unix_timestamp_1 On 6/26/14, 7:41 PM, Ken Lareau wrote: On Thu, Jun 26, 2014 at 1:45 PM, Mike Bayer mike...@zzzcomputing.com mailto:mike...@zzzcomputing.com wrote: minimal mapping + the query against that mapping. Okay, for the other method I needed

Re: [sqlalchemy] A question regarding hybrid properties, relationships and schema changes

2014-06-26 Thread Mike Bayer
right, so a few emails ago I said: you need to put .label('environment') on that column before it finds its way into subq. I dont have the mappings here to review. here's that: @environment.expression def environment(cls): return select(

Re: [sqlalchemy] Is it considered bad practice to have more than one session instance simultaneously in a web application?

2014-06-28 Thread Mike Bayer
On 6/28/14, 7:13 AM, Bao Niu wrote: My situation is like this: I am developing a web application, which has a Person class, which has /FirstName/ and /LastName/ attributes. Now I want to build their full name attribute and make this /full_name/ attribute queriable, by using hybrid_property,

Re: [sqlalchemy] subqueryload relationship in polymorphic base class with order_by on subclass column results in (ProgrammingError) missing FROM-clause entry

2014-06-30 Thread Mike Bayer
On 6/30/14, 6:01 PM, univerio wrote: Consider the following configuration: class Employee(Base): __tablename__ = employee id = Column(Integer, primary_key=True) type = Column(String(100)) cars = relationship(Car) __mapper_args__ = {

Re: [sqlalchemy] subqueryload relationship in polymorphic base class with order_by on subclass column results in (ProgrammingError) missing FROM-clause entry

2014-06-30 Thread Mike Bayer
On 6/30/14, 7:03 PM, Mike Bayer wrote: there's a little bit of a glitch here, however in any case, the ORDER BY would be from E.Engineer.specialty. The glitch is that the subq load at the moment seems to need an additional hint as to what its selecting from: session.query(E).select_from

Re: [sqlalchemy] subqueryload relationship in polymorphic base class with order_by on subclass column results in (ProgrammingError) missing FROM-clause entry

2014-06-30 Thread Mike Bayer
On 6/30/14, 7:29 PM, Jack Zhou wrote: Thanks for the quick response, Mike! that's all fixed in master / rel_1_0 and rel_0_9 branches (as you know I like to fix these deep polymorphic loader issues ASAP) On Mon, Jun 30, 2014 at 4:26 PM, Mike Bayer mike...@zzzcomputing.com mailto:mike

Re: [sqlalchemy] Postgresql - Index on a json field

2014-06-30 Thread Mike Bayer
SQLAlchemy's API allows CREATE INDEX via the Index construct: http://docs.sqlalchemy.org/en/rel_0_9/core/constraints.html?highlight=index#indexes On 6/30/14, 6:21 PM, Phillip Aquilina wrote: Using postgresql, I have a JSON type column. My understanding from their docs was that only jsonb

Re: [sqlalchemy] Postgresql - Index on a json field

2014-06-30 Thread Mike Bayer
I'm not familiar with any other style of index for this column type. If you can show me at http://www.postgresql.org/docs/9.4/static/datatype-json.html or wherever what specific DDL you're looking for, you can simply emit it using engine.execute(ddl). On 6/30/14, 11:02 PM, Phillip Aquilina

Re: [sqlalchemy] Postgresql - Index on a json field

2014-06-30 Thread Mike Bayer
INDEX foo ON publishers ((info - 'name')) On 7/1/14, 1:14 AM, Mike Bayer wrote: I'm not familiar with any other style of index for this column type. If you can show me at http://www.postgresql.org/docs/9.4/static/datatype-json.html or wherever what specific DDL you're looking for, you can

Re: [sqlalchemy] failed to locate a name error when using model with relationship

2014-07-01 Thread Mike Bayer
On 7/1/14, 1:17 PM, trusted...@gmail.com wrote: I have two classes, Artwork and Person. Artwork has a relationship to Person. However, when I try to use them, I get an error thrown: InvalidRequestError: When initializing mapper Mapper|Artwork|artwork, expression 'Person' failed to

Re: [sqlalchemy] Regarding the use of reciprocal relationships

2014-07-01 Thread Mike Bayer
On 7/1/14, 4:54 PM, Ken Lareau wrote: Related to one of my recent posted threads here, I'm recalling a certain conversation at PyCon where I was mentioning how a friend would define a many-to-many relationship by defining a relationship on both declarative classes involved, each pointing to

Re: [sqlalchemy] senseless warning messages escape python logging

2014-07-02 Thread Mike Bayer
we use the warnings filter to turn warnings into exceptions, either from the Python command line or programatically: https://docs.python.org/2/library/warnings.html https://docs.python.org/2/using/cmdline.html#cmdoption-W On 7/2/14, 3:26 AM, Hans-Peter Jansen wrote: Dear SQLAchemistas,

Re: [sqlalchemy] failed to locate a name error when using model with relationship

2014-07-02 Thread Mike Bayer
On 7/2/14, 10:21 AM, trusted...@gmail.com wrote: Hi Michael, thank you for the answer. Both classes are in the same file so I don't see how it could be possible that one class is used while other is not imported. Could you help me with that ? that would mean you're doing something that is

Re: [sqlalchemy] Postgresql - Index on a json field

2014-07-02 Thread Mike Bayer
/14, 1:14 AM, Mike Bayer wrote: I'm not familiar with any other style of index for this column type. If you can show me at http://www.postgresql.org/docs/9.4/static/datatype-json.html http://www.postgresql.org/docs/9.4/static/datatype-json.html

Re: [sqlalchemy] defaultdict functionality for association proxies

2014-07-02 Thread Mike Bayer
On 7/2/14, 11:15 AM, Brian Findlay wrote: I've since added an event listener to perform a calculation each time a UserCourse object is set: # Recalculate 'bar' after updating UserCourse @event.listens_for(UserCourse.grade, 'set') def foo(target, value, oldvalue, initiator): courses =

Re: [sqlalchemy] defaultdict functionality for association proxies

2014-07-02 Thread Mike Bayer
On 7/2/14, 2:59 PM, Brian Findlay wrote: Mike, thanks for the response. (1) foo updates a particular User attribute based on a calculation performed on the user.courses collection. I'm listening for the set event on UserCourse objects to trigger foo to update that User attribute, but that

Re: [sqlalchemy] (Semi-)automated way to adjust constraint names via Alembic?

2014-07-02 Thread Mike Bayer
Well you can get at the names that were used in the DB (using Inspector, or reflection) as well as the names that are in your metadata ([constraint for constraint in table.constraints for table in metadata.tables.values()], but as far as matching them up I'm not sure, it depends on what patterns

Re: [sqlalchemy] Automatically set primary key to None when deleted?

2014-07-02 Thread Mike Bayer
On 7/2/14, 10:05 PM, Paul Molodowitch wrote: Suppose I have a super simple table like this: class Dinosaur(Base): __tablename__ = 'dinosaurs' id = Column(Integer, primary_key=True) name = Column(String(255)) We assume that the id is set up in such a way that

Re: [sqlalchemy] failed to locate a name error when using model with relationship

2014-07-03 Thread Mike Bayer
On 7/3/14, 3:23 AM, trusted...@gmail.com wrote: Hi, Michael, here is the stack trace: File /home/andrey/projects/art/artFlask/api/artList.py, line 30, in post item = app_ctx.create_item_from_context() File /home/andrey/projects/art/artFlask/utils/app_ctx.py, line 53, in

Re: [sqlalchemy] how to query one-to-many relationships, in a complicated way?

2014-07-03 Thread Mike Bayer
On 7/2/14, 9:24 AM, Chung WONG wrote: Hi list, For this problem I am even having trouble think of a proper subject for it. I try my best to express as clear as possible and sorry for any confusions. Say there are three classes with relationship defined as below: class User(Base):

Re: [sqlalchemy] Automatically set primary key to None when deleted?

2014-07-03 Thread Mike Bayer
On 7/3/14, 1:01 PM, Paul Molodowitch wrote: That makes sense... but if if it really means nothing, and we shouldn't be looking at it, then why keep it's attributes around at all? because it is an additional step to actually erase the attributes and just hadn't been considered.

Re: [sqlalchemy] failed to locate a name error when using model with relationship

2014-07-03 Thread Mike Bayer
the package part first. then fix the import cycle. On 7/3/14, 1:39 PM, Mike Bayer wrote: this project needs: 1. a package 2. a setup.py file 3. a requirements.txt file I am running in each dependency indivdually as I get import errors. very painful. On 7/3/14, 1:19 PM, trusted

Re: [sqlalchemy] failed to locate a name error when using model with relationship

2014-07-03 Thread Mike Bayer
this project needs: 1. a package 2. a setup.py file 3. a requirements.txt file I am running in each dependency indivdually as I get import errors. very painful. On 7/3/14, 1:19 PM, trusted...@gmail.com wrote: Mike, here is the source for the models:

Re: [sqlalchemy] Reuse pre-defined Enum?

2014-07-03 Thread Mike Bayer
this works fine for me: def upgrade(): mytype = ENUM('a', 'b', 'c', create_type=False, name='myenum') mytype.create(op.get_bind(), checkfirst=False) op.create_table('t1', sa.Column('id', sa.Integer(), nullable=False), sa.Column('col1', mytype) )

Re: [sqlalchemy] failed to locate a name error when using model with relationship

2014-07-03 Thread Mike Bayer
model import Artwork ImportError: cannot import name Artwork well fix the package part first. then fix the import cycle. On 7/3/14, 1:39 PM, Mike Bayer wrote: this project needs: 1. a package 2. a setup.py file 3. a requirements.txt file I am

Re: [sqlalchemy] Automatically set cascade settings based on ON DELETE / ON UPDATE when reflecting?

2014-07-03 Thread Mike Bayer
On 7/3/14, 5:45 PM, Paul Molodowitch wrote: I noticed that sqlalchemy now properly sets the onpudate / ondelete properties of foreign keys when reflecting tables: https://bitbucket.org/zzzeek/sqlalchemy/issue/2183/support-on-delete-update-in-foreign-key However, it doesn't seem to set the

Re: [sqlalchemy] Automatically set cascade settings based on ON DELETE / ON UPDATE when reflecting?

2014-07-03 Thread Mike Bayer
On 7/3/14, 6:15 PM, Mike Bayer wrote: On 7/3/14, 5:45 PM, Paul Molodowitch wrote: I noticed that sqlalchemy now properly sets the onpudate / ondelete properties of foreign keys when reflecting tables: https://bitbucket.org/zzzeek/sqlalchemy/issue/2183/support-on-delete-update-in-foreign-key

Re: [sqlalchemy] failed to locate a name error when using model with relationship

2014-07-05 Thread Mike Bayer
On 7/3/14, 5:20 PM, trusted...@gmail.com wrote: Muchos grasias, Michael! Issue resolved. There were a couple of other ForeignKey issues, seems to be okay now. So far I understand that there is a lot to learn for me, so I was wondering - do you by chance accept apprentices ? I would be

Re: [sqlalchemy] Postgresql - Index on a json field

2014-07-05 Thread Mike Bayer
On 7/5/14, 3:14 PM, Phillip Aquilina wrote: I finally had a chance to try this with the inspector and quickly discovered it doesn't support expression-based indexes with this warning, Skipped unsupported reflection of expression-based index some_index. I can patch this out locally for my own

Re: [sqlalchemy] Modified mapping in composite association proxy causes conflict with persistent instance

2014-07-08 Thread Mike Bayer
a test case is attached, show me the failure please, thanks. On 7/8/14, 10:59 AM, Brian Findlay wrote: Hi Mike, I'm using your variant on the 'unique object' recipe (see previous posting http://goo.gl/I1buRz) with some composite association proxies. Recently, the data I've been working

Re: [sqlalchemy] advice sought : `commit()` without expiring from the session ?

2014-07-08 Thread Mike Bayer
you can make a new Session() with expire_on_commit=False, that can be from your sessionmaker. the settings you apply there override whats in the original factory. Though for status logging I tend to just use a separate Session/transaction for that, that way the main transaction can maintain

Re: [sqlalchemy] unit tests failing on 0.9.6

2014-07-08 Thread Mike Bayer
how are you running them? it isn't reporting any failure, this seems like it's finding a bad test case. do you have any test.py type stuff it might be hitting? On 7/8/14, 5:56 PM, Jason Newton wrote: Any thoughts on why the unit testing is failing? platform linux2 -- Python 2.7.6 --

Re: [sqlalchemy] unit tests failing on 0.9.6

2014-07-09 Thread Mike Bayer
OK what if you just run it via py.test ?the distutils/setuptools approach is so often problematic. issue appeared in 0.9.6, not 0.9.5 ? On 7/9/14, 3:01 AM, Jason Newton wrote: Yes, it seems to me like it gets to the end and then commits suicide just before returning, but I wasn't able

Re: [sqlalchemy] unit tests failing on 0.9.6

2014-07-09 Thread Mike Bayer
OK this is fixed now, I hope. On 7/9/14, 9:52 AM, Mike Bayer wrote: OK what if you just run it via py.test ?the distutils/setuptools approach is so often problematic. issue appeared in 0.9.6, not 0.9.5 ? On 7/9/14, 3:01 AM, Jason Newton wrote: Yes, it seems to me like it gets

Re: [sqlalchemy] problems with mysql reflect

2014-07-09 Thread Mike Bayer
On 7/9/14, 3:41 PM, Paul Molodowitch wrote: I just ran into the same problem, using python 2.6 + sqlalchemy 0.9.4 / 0.9.6 + MySQL. The problem in my case IS definitely related to python 2.6 - basically, python 2.6 doesn't allow unicode keywords, while 2.7 does. Ie, if you do this: def

Re: [sqlalchemy] Re: Bound parameter on Postgres/psycopg2 Range data types

2014-07-10 Thread Mike Bayer
On 7/10/14, 2:46 PM, Brian Findlay wrote: Sqlalchemy seems to be coercing the upper boundary to be exclusive. See below tests (will need to change postgres db if you want to run them). from sqlalchemy import * from sqlalchemy.orm import * from sqlalchemy.ext.declarative import

Re: [sqlalchemy] problems with mysql reflect

2014-07-10 Thread Mike Bayer
On 7/10/14, 3:49 PM, Paul Molodowitch wrote: Whoops! Just noticed this was the totally wrong traceback! Here's the correct trace: Traceback (most recent call last): File stdin, line 1, in module File test.py, line 155, in module metadata.reflect(db.engine,

Re: [sqlalchemy] StaleDataError/ObjectDeletedError

2014-07-11 Thread Mike Bayer
On 7/11/14, 5:07 PM, Staszek wrote: On 2014-02-01 00:09, Michael Bayer wrote: On Jan 31, 2014, at 5:24 PM, lars van gemerden l...@rational-it.com mailto:l...@rational-it.com wrote: Hi, all I am running into these 2 errors and have run out of ideas what to do about it (also because i don't

Re: [sqlalchemy] self-referential relationship and aliases

2014-08-11 Thread Mike Bayer
For a fancy column_property like that you likely need to define it after the fact and attach it to the class. There's some new features I have in the works for 1.0 to make that easier. The general idea is: class MyClass(Base): # ... alias = aliased(MyClass) stmt =

Re: [sqlalchemy] Trying to get tables to be created by unit tests

2014-08-11 Thread Mike Bayer
On 08/11/2014 04:37 PM, alchemy1 wrote: I have combined several examples I've found to try to get the 'transactional-style' of unit tests to work, where you roll back the database after each test. However when I run this, the test fails when trying to insert the object with DBSession.add,

Re: [sqlalchemy] SAWarnings when using history_meta.py versioning and Inheritance.

2014-10-17 Thread Mike Bayer
On 10/17/2014 02:52 PM, JPLaverdure wrote: Hello, It seems a number of SAWarnings are being thrown whenever I instantiate Versioned objects which make use of inheritance: | SAWarning:Implicitlycombining column container_history.changed withcolumn barcoded_container_history.changed under

[sqlalchemy] SQLAlchemy 0.3.9 Released

2007-07-15 Thread mike bayer
SQLAlchemy 0.3.9 Released Version 0.3.9 of SQLAlchemy is released. This is probably not the last of the 0.3 series, but it's the last major set of changes for this line; subsequent releases should probably be only for important bug fixes. 0.3.9includes a lot of important bug fixes as usual, but

Re: [sqlalchemy] Long transactions with SQLite (and of course locks)

2015-03-31 Thread Mike Bayer
On 3/31/15 7:23 PM, Eric Smith wrote: Environment: SQLAlchemy 0.9.7, SQLite back-end, autoflush=True, mostly using scoped session, multi-platform Python 2.7 I'm working on a multi-threaded app, but with fairly low concurrency (user actions and scheduled tasks are on different threads, for

Re: [sqlalchemy] Inherited class column override

2015-04-01 Thread Mike Bayer
On 4/1/15 4:55 AM, Pierre B wrote: Unfortunately I'm inheriting the relational model from an old application. I have dozens of tables using a single junction table for associations. I can not completely redesign my relational model because it needs to be compatible with the old application.

Re: [sqlalchemy] 0.9.7: Intermittently find a dead weakref to a listens_for function while checking _stored_in_collection of a registry

2015-04-02 Thread Mike Bayer
On 4/2/15 4:28 PM, Evan James wrote: Hi folks, While running my test suite, I hit an issue with the following stack trace: | ERROR at setup of test_track_before_delete request =SubRequest'database_session'forFunction'test_track_before_delete',engine =Engine(sqlite:///test.db)

[sqlalchemy] SQLAlchemy 1.0.0b5 Released

2015-04-03 Thread Mike Bayer
SQLAlchemy release 1.0.0b5 is now available. This release is yet another set of fixes for issues reported by beta testers. At this point, 1.0.0 is ready to go and should be released very soon. In preparation for 1.0.0, production installations that haven't yet been tested in the 1.0 series

Re: [sqlalchemy] Decimals generated as strings in query

2015-04-13 Thread Mike Bayer
On 4/13/15 2:25 PM, Gabriel Becedillas wrote: Dear Michael, Thanks a lot for your reply. In trying to narrow the problem as much as possible, I missed something important in my example. I'm actually doing an UPDATE, not a SELECT. When I wrote 'I tried casting my decimals using

Re: [sqlalchemy] Decimals generated as strings in query

2015-04-13 Thread Mike Bayer
On 4/13/15 11:50 AM, Gabriel Becedillas wrote: Dear all, I have a table that has 2 numeric columns, and I'm writing a query that performs some arithmetic on the filter clause between those columns and a Decimal. The problem that I'm facing is that I don't get any results at all. After a

Re: [sqlalchemy] polymorphic inheritance and unique constraints

2015-04-13 Thread Mike Bayer
On 4/13/15 4:59 PM, Richard Gerd Kuesters | Pollux Automation wrote: well, this didn't work with upstream 1.0 - sorry, I was in another project and couldn't test it myself. you're not doing the same thing this user was doing in any case... Traceback (most recent call last): File

Re: [sqlalchemy] Non backwards-compatible changes in 1.0? Lots of suddenly failing tests here.

2015-04-20 Thread Mike Bayer
On 4/20/15 12:56 PM, Guido Winkelmann wrote: I just tested, the problem is still present in the current master (bd61e7a3287079cf742f4df698bfe3628c090522 from github). Guido W. can you please try current master at least as of a3af638e1a95d42075e25e874746, thanks. -- You received this

[sqlalchemy] SQLAlchemy 1.0.1 Released

2015-04-23 Thread Mike Bayer
SQLAlchemy release 1.0.1 is now available. This is a quick bug-fix release that repairs several new regressions identified in the 1.0.0 release, not found during the beta period. All users of 1.0.0 are encouraged to upgrade to 1.0.1. Key elements of this release include fixes regarding the

Re: [sqlalchemy] Access __tablename__ in server_defaults?

2015-04-23 Thread Mike Bayer
if you are using __tablename__ what happens if you just refer to cls.__tablename__ in that method ? On 4/23/15 3:46 PM, Jacob Magnusson wrote: Would it somehow be possible to access the __tablename__ in server_default? What I'm looking for is something like this: |class

Re: [sqlalchemy] Add information to reflected tables

2015-04-23 Thread Mike Bayer
On 4/23/15 5:15 PM, Jeffrey Yan wrote: I have a couple of tables that I want to reflect. The first is a data table where one of the columns is a foreign key to the second table. If I used SQLAlchemy declarative_base, a query might look something like this: |

Re: [sqlalchemy] Generating Correlated Subqueries

2015-04-19 Thread Mike Bayer
On 4/19/15 9:36 AM, ThereMichael wrote: Sorry, sometimes you get so deep into something you forget everyone else isn't familiar with the problem. As an example, here's what I'm looking for: select things.id, count(comments.type) from things things, comments comments where

  1   2   3   4   5   6   7   8   9   10   >