[sqlalchemy] python setup.py develop doesn't install nose

2010-04-06 Thread Chris Withers
...python setup.py test probabyl would, but only for the test run. Might be worth mentioning in README.unittests that you need to manually install nose... cheers, Chris -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group,

Re: [sqlalchemy] python setup.py develop doesn't install nose

2010-04-06 Thread Chris Withers
Michael Bayer wrote: Chris Withers wrote: ...python setup.py test probabyl would, but only for the test run. Might be worth mentioning in README.unittests that you need to manually install nose... this is not clear enough ? As of 0.5.5, unit tests are run using nose. Documentation

[sqlalchemy] inheriting __mapper_args__ and classproperty

2010-04-06 Thread Chris Withers
Okay, so, this is convoluted and painful. We have a project where we use a single table inheritence setup to model reports. Each report has email addresses to send it to, when to run it, etc, but is mapped to an individual class for the implementation of what goes into the report. Now, to

Re: [sqlalchemy] inheriting __mapper_args__ and classproperty

2010-04-07 Thread Chris Withers
Michael Bayer wrote: I reworked your mixin system in rae3ec57eea8c to fully traverse all of cls.__mro__ every time and to be very explicit about rules for the current class vs. classes that we definitely know are mixins. So the above works as well as if you just put the ComputedMapperArgs on

Re: [sqlalchemy] inheriting __mapper_args__ and classproperty

2010-04-07 Thread Chris Withers
Michael Bayer wrote: Chris Withers wrote: I see how you've fixed this for 0.6, but it makes me wonder why the __table_args__ check is there at all? They're essentially benign, right? (since in the test case above, it really doesn't make sense for Specific to have __table_args__ inside

[sqlalchemy] mixins vs single table inheritence

2010-04-08 Thread Chris Withers
Hi Again, So here's a test case ready to drop onto the end of test_declarative.py: def test_mapper_args_single_table(self): class TableNameMixin: @classproperty def __tablename__(cls): return cls.__name__.lower() class CommonColumns:

Re: [sqlalchemy] mixins vs single table inheritence

2010-04-08 Thread Chris Withers
Michael Bayer wrote: are you wondering*why* this happens ? its because your mixin is giving all classes a __tablename__. Well, that's only a symptom of the problem, here's another example: def test_mapper_args_single_table(self): class CommonColumns: id =

[sqlalchemy] further restricting a query provided as raw sql

2010-04-15 Thread Chris Withers
Hi All, I have a big set of queries provided as raw sql like: SELECT somestuff FROM somewhere WHERE some_date = :from_date AND some_date = :to_date That's fine, I just blat it at session.execute and provide from_date and to_date in the params dict. However, they now wany to supply

Re: [sqlalchemy] further restricting a query provided as raw sql

2010-04-15 Thread Chris Withers
Michael Bayer wrote: you have to rewrite your SQL to support the number of values in the IN clause for each parameter set. Hmm :'( While my code knows the number of values, they don't, and it may vary from when they write the SQL to when that SQL gets executed by my code... Chris -- You

Re: [sqlalchemy] adapt MSVarchar to SLString

2010-04-16 Thread Chris Withers
Tony wrote: I was trying to copy a MS Sql server database to a Sqlite database (with SA 5.8), How? What code were you using? Chris -- Simplistix - Content Management, Batch Processing Python Consulting - http://www.simplistix.co.uk -- You received this message because you are

Re: [sqlalchemy] session usage lifecycle

2010-04-19 Thread Chris Withers
Michael Bayer wrote: On Mar 12, 2010, at 6:54 AM, Chris Withers wrote: Got this error this morning: File /usr/lib/python2.5/site-packages/SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/orm/session.py, line 247, in _assert_is_active The transaction is inactive due to a rollback

[sqlalchemy] another confusing error message

2010-04-19 Thread Chris Withers
Michael Bayer wrote: On Mar 12, 2010, at 6:54 AM, Chris Withers wrote: Got this error this morning: File /usr/lib/python2.5/site-packages/SQLAlchemy-0.5.8-py2.5.egg/sqlalchemy/orm/session.py, line 247, in _assert_is_active The transaction is inactive due to a rollback

Re: [sqlalchemy] SQLAlchemy 0.6.0 released

2010-04-19 Thread Chris Withers
Michael Bayer wrote: The first official 0.6 release of SQLAlchemy is now available. Yay! Congrats :-) Chris -- Simplistix - Content Management, Batch Processing Python Consulting - http://www.simplistix.co.uk -- You received this message because you are subscribed to the

Re: [sqlalchemy] case sensitive Unicode and String columns

2010-04-19 Thread Chris Withers
Michael Bayer wrote: the MySQL string types support MySQL's collation flags so you can get close to it for at least that platform. But then you aren't platform independent. Not sure why you're so averse to creating types. The interface could not be simpler. When i used Hibernate, there was

Re: [sqlalchemy] case sensitive Unicode and String columns

2010-04-20 Thread Chris Withers
Michael Bayer wrote: Please let me know if there's a better way! you should use TypeDecorator.load_dialect_impl(dialect), check the name of the dialect, Why the name rather than doing: if isinstance(dialect,MySQLDialect): ? then return either MSString(arguments) or

[sqlalchemy] docs for TypeDecorators

2010-04-20 Thread Chris Withers
Hi All, Are there any other docs for using and creating TypeDecorators than these: http://www.sqlalchemy.org/docs/05/reference/sqlalchemy/types.html#custom-types The following sections: http://www.sqlalchemy.org/docs/05/reference/sqlalchemy/types.html#sqlalchemy.types.TypeDecorator.__init__

Re: [sqlalchemy] docs for TypeDecorators

2010-04-20 Thread Chris Withers
Michael Bayer wrote: http://www.sqlalchemy.org/docs/05/reference/sqlalchemy/types.html#sqlalchemy.types.TypeDecorator.__init__ ...are a little less detailed than they could be ;-) Let me talk to one of our committers to see if they can help us. Hey Chris - want to beef up the docs for

Re: [sqlalchemy] bug in sqllite dialect?

2010-04-20 Thread Chris Withers
Michael Bayer wrote: the whole ugly discussion is at http://www.sqlalchemy.org/trac/ticket/1759 Speshul... *sigh* I'm glad I don't have your responsibilities ;-) Chris -- Simplistix - Content Management, Batch Processing Python Consulting - http://www.simplistix.co.uk -- You

Re: [sqlalchemy] further restricting a query provided as raw sql

2010-04-23 Thread Chris Withers
to mongodb :) On Apr 15, 2010, at 10:46 AM, Chris Withers wrote: Michael Bayer wrote: you have to rewrite your SQL to support the number of values in the IN clause for each parameter set. Hmm :'( While my code knows the number of values, they don't, and it may vary from when they write

Re: [sqlalchemy] further restricting a query provided as raw sql

2010-04-26 Thread Chris Withers
Michael Bayer wrote: Any serious ideas or should I just go sulk in the corner? you have to use IN, and you have to generate the SQL every time based on the number of values you'd like to put into the IN. Does SA have any helper code anywhere for this? Chris -- You received this message

[sqlalchemy] correct way to handle 'MySQL server has gone away'?

2010-04-26 Thread Chris Withers
Chris Withers wrote: raise exc.InvalidRequestError(Can't reconnect until invalid transaction is rolled back) sqlalchemy.exc.InvalidRequestError: Can't reconnect until invalid transaction is rolled back Asking here as it sounds like it might be related. It occurred transiently, though

Re: [sqlalchemy] further restricting a query provided as raw sql

2010-04-28 Thread Chris Withers
Michael Bayer wrote: we have the in_() construct. It should be in the ORM and SQL expression tutorials: t1 = Table('mytable', metadata, Column('foo', String)) select([t1]).where(t1.c.foo.in_(['a', 'b', 'c'])) However, that requires table/column objects which I don't have. Are the innards

Re: [sqlalchemy] session lifecycle and wsgi

2010-04-28 Thread Chris Withers
Diana Clarke wrote: I'm a bit hesitant to share what I've done, b/c it's still a work in progress etc, but here goes: MySQL MyISAM, wait_timeout=28800 You have no transactions, so I'm not sure why you're worrying about them... Switch to InnoDB if you want transactions... Finally,

Re: [sqlalchemy] Re: session lifecycle and wsgi

2010-04-28 Thread Chris Withers
Laurence Rowe wrote: Chris, This is what the combination of repoze.tm2/transaction and zope.sqlalchemy does for you. You don't have to do anything special other than that. It doesn't do the .remove(). BFG currently has a bit of horribleness to make that work. I'd like to get rid of it or make

Re: [sqlalchemy] session lifecycle and wsgi

2010-04-28 Thread Chris Withers
jason kirtland wrote: On Wed, Apr 28, 2010 at 7:52 AM, Chris Withers ch...@simplistix.co.uk wrote: Diana Clarke wrote: Finally, we're using pylons and are removing the contextual session in the finally clause of the base controller's __call__ method. class BaseController(WSGIController

Re: [sqlalchemy] declarative commit hook - onCommit()?

2010-04-28 Thread Chris Withers
Daniel Robbins wrote: Let's say that when a database record is added or updated, I need to perform some arbitrary action (in my case, ensuring that data in other tables is consistent with what is being committed.) What mechanisms are suggested for this? Mapper extesions:

Re: [sqlalchemy] session lifecycle and wsgi

2010-04-28 Thread Chris Withers
Michael Bayer wrote: If finishing with a .remove() is a big deal in your environment, which it seems like it is, you could do a .remove() at the start of the request instead. You really don't need the remove() if you have definitely called commit() or rollback() last, and you have

Re: [sqlalchemy] session lifecycle and wsgi

2010-04-29 Thread Chris Withers
Michael Bayer wrote: if your application keeps a handle on objects after the request is complete, and then passed them somewhere else, like a background thread or something, then the subsequent request is going to be potentially touching those objects at the same time. This would all be pretty

Re: [sqlalchemy] Re: session lifecycle and wsgi

2010-04-29 Thread Chris Withers
Laurence Rowe wrote: On Apr 28, 4:38 pm, Chris Withers ch...@simplistix.co.uk wrote: Laurence Rowe wrote: Chris, This is what the combination of repoze.tm2/transaction and zope.sqlalchemy does for you. You don't have to do anything special other than that. It doesn't do the .remove(). BFG

Re: [sqlalchemy] further restricting a query provided as raw sql

2010-05-04 Thread Chris Withers
Michael Bayer wrote: Are the innards of in_ exposed anywhere for public consumption or should I avoid? from sqlalchemy.sql import column column(anything_you_want).in_(['a', 'b', 'c']) Thanks, that's exactly what I was looking for... Chris -- You received this message because you are

Re: [sqlalchemy] session lifecycle and wsgi

2010-05-04 Thread Chris Withers
Michael Bayer wrote: (I'm guessing session.merge will whine if handed an object that is already in another session?) mm no merge() leaves the original unaffected. it copies state to an instance internal to the session. this is very clear here:

[sqlalchemy] is sqlalchemy-migrate the right way to go?

2010-05-17 Thread Chris Withers
Hi All, I want our production systems to start caring about the versions of their schemas. sqlalchemy-migrate was the first project I came across which addresses this. What other projects should I look at in this area, or is sqlalchemy-migrate the obvious choice? If it is, how can I, in my

Re: [sqlalchemy] is sqlalchemy-migrate the right way to go?

2010-05-17 Thread Chris Withers
Michael Bayer wrote: sqlalchemy-migrate is the obvious choice.I am also developing a micro-migrations system called Alembic (http://bitbucket.org/zzzeek/alembic) If we start with sqlalchemy-migrate, do you reckon switching to Alembic when it's mature would be feasible? Chris --

Re: [sqlalchemy] Update table from a text file in a speedest way

2010-05-20 Thread Chris Withers
emanuele.fan...@gmail.com wrote: This way the program works, but it's very slow. There are any way to speed up the process, the text file contains 400.000 record and it's 72 MB. Use your databases method for loading from a file (eg: MySQL's load data infile) Write a python script to get your

[sqlalchemy] Re: Alembic

2010-05-21 Thread Chris Withers
Michael Bayer wrote: It's not clear that Alembic has real advantages over Migrate. Its simpler for sure since it only is for SQLA 0.6 and up and doesn't attempt to do the crazy things Migrate does like versioning SQLite databases. I'm going to attempt to handle branching (but already that

Re: [sqlalchemy] Re: Mixin issues

2010-05-22 Thread Chris Withers
Michael Bayer wrote: yes, but I'd rather you keep working on declarative Mixin issues :) (there's more in trac). I haven't had any notifications :-/ Feel free to assign the ones you're thinking of to me and I'll try and take a look... Chris -- Simplistix - Content Management, Batch

[sqlalchemy] scoped_session in a single threaded environment?

2010-05-26 Thread Chris Withers
Hi all, Is there any harm in using scoped_session in a single threaded environment? cheers, Chris -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group,

[sqlalchemy] mysql vs sqlite for testing

2010-05-27 Thread Chris Withers
Hi All, We currently run unit tests against sqlite in memory but deploy against MySQL. http://stackoverflow.com/questions/2716847/sqlalchemy-sqlite-for-testing-and-postgresql-for-development-how-to-port ...suggests this is a bad idea. I'm inclined to agree, but... ...running our unit tests

Re: [sqlalchemy] mysql vs sqlite for testing

2010-05-28 Thread Chris Withers
Michael Bayer wrote: How do people get around this? What's best practice in this area? your test suite ideally wouldn't be tearing down and building up tables many times. Correct ;-) For an application where the testing is against a fixed set of tables (i.e. not at all like SQLA's own

[sqlalchemy] how can I tell if an engine supports two phase commit?

2010-06-01 Thread Chris Withers
if 'sqlite' not in str(engine.url) ...seems a little clunky to me ;-) Chris -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to

Re: [sqlalchemy] how can I tell if an engine supports two phase commit?

2010-06-01 Thread Chris Withers
Michael Bayer wrote: engine.dialect.name in ('postgresql', 'mysql') Heh, so no API to future proof my code for when the Oracle connector becomes 2 phase? ;-) Chris -- Simplistix - Content Management, Batch Processing Python Consulting - http://www.simplistix.co.uk -- You

[sqlalchemy] cross-database joins with MySQL

2010-06-11 Thread Chris Withers
Hi All, We have engines set up like: engine1 = create_engine('mysql://username:passw...@server/db1') engine2 = create_engine('mysql://username:passw...@server/db2') ..and then have them bound to separate sessions, with separate model classes mapped to them. Now, mysql supports cross

[sqlalchemy] MapperExtension examples relating to versioning

2010-06-29 Thread Chris Withers
Hi All, I'm looking for examples of MapperExtensions. Specifically, I'm looking to implement one that creates new rows when certain attributes of an object changes. I'm not sure if this is the right approach, so here's some pseudocode of how I'd like to use the end result: class

Re: [sqlalchemy] mysql vs sqlite for testing

2010-06-29 Thread Chris Withers
Just bumped into these questions which I still don't understand :-S Chris Withers wrote: I use setup/teardowns like this for this purpose (assume scoped_session, which yes you should probably use all the time so that the session is accessed by a single reference): Where do you actually drop

Re: [sqlalchemy] cross-database joins with MySQL

2010-06-29 Thread Chris Withers
Michael Bayer wrote: We have engines set up like: engine1 = create_engine('mysql://username:passw...@server/db1') engine2 = create_engine('mysql://username:passw...@server/db2') ..and then have them bound to separate sessions, with separate model classes mapped to them. Now, mysql supports

[sqlalchemy] doing stuff in MapperExtension's before_insert and before_update

2010-06-29 Thread Chris Withers
Hi All, Is it legit/okay/bad to do things in a MapperExtension's before_insert and/or before_update methods? Specifically, the following: - change the primary key of the instance by deleting it so that the dataabse assigns a new primary key? - do a query to update an existing row? (where

Re: [sqlalchemy] SQL Alchemy for bigger enterprise application

2010-06-29 Thread Chris Withers
Dan @ Austria wrote: Is sqlalchemy the most prominent orm for python? yes. Is it suitable to write larger enterprise applications? yes. Are there any drawbacks to sqlalchemy? sure, as with any piece of software... Are there any other big orm projects for python, which one should

Re: [sqlalchemy] doing stuff in MapperExtension's before_insert and before_update

2010-06-29 Thread Chris Withers
Michael Bayer wrote: Specifically, the following: - change the primary key of the instance by deleting it so that the dataabse assigns a new primary key? that wont work. you need to take the object and call make_transient() on it, re-add it to the session. Where is make_transient

Re: [sqlalchemy] doing stuff in MapperExtension's before_insert and before_update

2010-06-29 Thread Chris Withers
Michael Bayer wrote: for thing in session.query(MyThing).all(): ... print x.id, x.name, x.value, x.valid_from, x.valid_to 1, 'foo', 100, 2010-06-29 09:00, 2010-06-29 09:05 2, 'foo', 200, 2010-06-29 09:05, None `x` used to correspond to the row with id of 1, but now corresponds to the row

Re: [sqlalchemy] doing stuff in MapperExtension's before_insert and before_update

2010-06-29 Thread Chris Withers
Michael Bayer wrote: - I take it there are no problems with specifying multiple extensions to sessionmaker? (we need zope.sqlalchemy's extension too) What effect does order of extensions have? calls them in order heh, so what order to put 'em in? I'm guessing zope.sqlalchemy's one should

[sqlalchemy] MapperOptions...

2010-07-01 Thread Chris Withers
...I think I may want to use session.query(...).options(...) to work with the versioning stuff I'm working on to express queries along the lines of: - tell me what the state of play was at 2pm yesterday - give me back new revisions of all objects between 2pm and 4pm yesterday - give me one

Re: [sqlalchemy] doing stuff in MapperExtension's before_insert and before_update

2010-07-01 Thread Chris Withers
Michael Bayer wrote: The recursion overflow is fixed and make_transient now removes expiration flags. In the latest tip you can now say: session.expire(object, ['id']) make_transient(object) or alternatively: make_transient(object) object.id = None and the

[sqlalchemy] models in different packages, often declaratively defined

2010-07-01 Thread Chris Withers
Hi All, Suppose I have packageA that defines: from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() class User(Base) __tablename__ = 'user' ... Now, I have a packageB that defines: from sqlalchemy.ext.declarative import declarative_base Base =

Re: [sqlalchemy] Column order with declarative base

2010-07-01 Thread Chris Withers
Mike Lewis wrote: I'm trying to do some DDL creation with declarative base. THe problem I am running into is that I'm using a mixin, and it seems that the order the columns are being created in is different than the order they're declared with. Is there any way to control this? Please

Re: [sqlalchemy] Re: Column order with declarative base

2010-07-02 Thread Chris Withers
Michael Bayer wrote: I'd welcome any patches in this regard since I don't usually deal with the mixin feature. fine, how about Chris works up the unit test for it: Done and pushed back to tip with the fix. cheers, Chris -- You received this message because you are subscribed to the

Re: [sqlalchemy] altering tables with sqlite

2010-07-04 Thread Chris Withers
Carl Brewer wrote: In sqlite I hand-hacked a change to the table that needed changing, adding a field (which is not a linked field in any way), using alter table riders add gender string(1) That's fair enough, although you might look at the sqlalchemy-migrate or alembic packages for more

[sqlalchemy] DropEverything across all supported database types

2010-07-05 Thread Chris Withers
Hi All, I'm looking to use: http://www.sqlalchemy.org/trac/wiki/UsageRecipes/DropEverything Sadly, the recipe uses hard-coded sql which doesn't work with MySQL. I'd like to change it so that it's database-agnostic like the rest of SQLAlchemy. My hunting has lead me to:

Re: [sqlalchemy] DropEverything across all supported database types

2010-07-05 Thread Chris Withers
Chris Withers wrote: Hi All, I'm looking to use: http://www.sqlalchemy.org/trac/wiki/UsageRecipes/DropEverything Sadly, the recipe uses hard-coded sql which doesn't work with MySQL. I'd like to change it so that it's database-agnostic like the rest of SQLAlchemy. My hunting has lead me

Re: [sqlalchemy] DropEverything across all supported database types

2010-07-05 Thread Chris Withers
Chris Withers wrote: Well, my current attempt is: from sqlalchemy.engine import reflection from sqlalchemy.schema import ( MetaData, Table, DropTable, ForeignKeyConstraint, DropConstraint, ) conn = engine.connect

Re: [sqlalchemy] DropEverything across all supported database types

2010-07-05 Thread Chris Withers
Michael Bayer wrote: why don't you create a ForeignKeyConstraint that only has the name field ? DropConstraint doesn't need anything more than just the name. 'cos I don't know what I'm doing ;-) also here, again we only need a name. Make yourself a fake table: t = Table(table_name,

[sqlalchemy] GlobalFilter recipe blows up with 0.6.1

2010-07-05 Thread Chris Withers
Hi All, This recipe: http://www.sqlalchemy.org/trac/wiki/UsageRecipes/GlobalFilter ...blows up as follows in SA 0.6.1 on Python 2.6 around here: parents = session.query(Parent).\ options( TemporalOption( datetime.datetime(2009, 10, 16, 12, 00, 00),

Re: [sqlalchemy] GlobalFilter recipe blows up with 0.6.1

2010-07-05 Thread Chris Withers
Michael Bayer wrote: frozendict has a union() method. query._params = query._params.union(...) Okay, I've updated the GlobalFilter and DropEverything recipes :-) Chris -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group,

Re: [sqlalchemy] doing stuff in MapperExtension's before_insert and before_update

2010-07-07 Thread Chris Withers
Michael Bayer wrote: The recursion overflow is fixed and make_transient now removes expiration flags. In the latest tip you can now say: session.expire(object, ['id']) make_transient(object) or alternatively: make_transient(object) object.id = None and the

Re: [sqlalchemy] SQLAlchemy 0.6.2 Released

2010-07-07 Thread Chris Withers
Michael Bayer wrote: - Declarative mixins can do everything now. You need to use sqlalchemy.util.classproperty in most cases to do it. Cool, but the spelling is a little cumbersome: class MyMixin: @classproperty def type_(cls): return Column(String(50)) It'd feel more

Re: [sqlalchemy] SQLAlchemy 0.6.2 Released

2010-07-07 Thread Chris Withers
Michael Bayer wrote: mixin(foo) is the most practical of the ideas above, but someone can easily create that themselves. Indeed,, I was just wondering if this should be in the core and the recommended way of doing this? Chris -- You received this message because you are subscribed to the

Re: [sqlalchemy] doing stuff in MapperExtension's before_insert and before_update

2010-07-07 Thread Chris Withers
Michael Bayer wrote: Did this make it into 0.6.2? If so, I'll update the recipe... yeah and the recipe should be up to date. Cool :-) Chris -- Simplistix - Content Management, Batch Processing Python Consulting - http://www.simplistix.co.uk -- You received this message

Re: [sqlalchemy] Re: Why does SA (only 0.6.x) read data from n:m relationships when updating the parent table?

2010-07-07 Thread Chris Withers
Michael Bayer wrote: can you try out the latest hg tip for me please, I still feel like releasing this today: http://hg.sqlalchemy.org/sqlalchemy/archive/default.tar.gz I've got a brown bag you can borrow if it's that serious ;-) Chris -- Simplistix - Content Management, Batch Processing

[sqlalchemy] object dirtiness from the session's perspective?

2010-07-08 Thread Chris Withers
Hi All, I'm working on a variation of this recipe: http://www.sqlalchemy.org/trac/wiki/UsageRecipes/VersionedRows ...and I've got a couple of questions about changed objects: - do objects end up in session.dirty as a result of attributes being set or changed? For example: class

Re: [sqlalchemy] blocking on Base.metadata.drop_all() in test

2010-07-08 Thread Chris Withers
zende wrote: Base.metadata.drop_all() completely blocks in the tearDown method of some of my tests. What database backend are you using *in the tests*? Where is the code blocking? (ie: when you hit ctrl-c, you should get a traceback, it would be handy to see that...) cheers, Chris --

Re: [sqlalchemy] Comparable properties

2010-07-08 Thread Chris Withers
Oliver Beattie wrote: @property def is_visible(self): return (self.enabled and not self.is_deleted) This can clearly be mapped quite easily to SQL expression `Klass.enabled == True Klass.is_deleted == False` You could always add a class-level attribute that stored this...

Re: [sqlalchemy] Using the declarative base across projects

2010-07-08 Thread Chris Withers
thatsanicehatyouh...@mac.com wrote: This is a bit tricky to explain. Imagine I have one database, and I create a project (1) to work with that database (connections, table class definitions, etc.). That is standalone (to me). I have another completely separate database (2) on another host

Re: [sqlalchemy] Comparable properties

2010-07-08 Thread Chris Withers
King Simon-NFHD78 wrote: @hybrid def is_visible(self): return (self.enabled == True) (self.is_deleted == False) Yeah, having to write something that works as both plain python and a sql layer construct seems a little brittle. I wonder if a decorator could be knocked up which would

[sqlalchemy] c-extensions have to be explicitly requested?!

2010-07-08 Thread Chris Withers
Hi All, I'm a bit surprised to find that you have to ask for the new C extensions in 0.6 to be explicitly compiled. It also appears that the way of requesting this isn't compatible with build tools like a pip requirements file or buildout. What was the reason for that? If it was purely in

[sqlalchemy] docs for History object?

2010-07-08 Thread Chris Withers
Hi All, Where can I find documentation of the History objects used by the orm layer? In particular, how come each of .added, .unchanged and .deleted is a sequence? Are history objects always around or is there a performance hit for using them? cheers, Chris -- You received this message

[sqlalchemy] make_transient vs expunge

2010-07-08 Thread Chris Withers
Hi All, My flow of questions continues ;-) What's the difference beween make_transient(instance), where I guess make_transient comes from sqlalchemy.org, and session.expunge(instance)? cheers, Chris -- You received this message because you are subscribed to the Google Groups sqlalchemy

Re: [sqlalchemy] make_transient vs expunge (correction)

2010-07-08 Thread Chris Withers
Chris Withers wrote: Hi All, My flow of questions continues ;-) What's the difference beween make_transient(instance), where I guess make_transient comes from sqlalchemy.org, ...er, that's sqlachemy.orm... Chris -- You received this message because you are subscribed to the Google Groups

Re: [sqlalchemy] object dirtiness from the session's perspective?

2010-07-08 Thread Chris Withers
Lance Edgar wrote: - do objects end up in session.dirty as a result of attributes being set or changed? Setting an attribute is enough for the instance to wind up in Session.dirty, according to http://www.sqlalchemy.org/docs/reference/orm/sessions.html#sqlalchemy.orm.session.Session.dirty

Re: [sqlalchemy] c-extensions have to be explicitly requested?!

2010-07-08 Thread Chris Withers
Michael Bayer wrote: http://svn.zope.org/zope.interface/trunk/setup.py?view=auto we wanted to annoy buildout/setuptools/Glyph as much as possible, and I am happy to say we succeeded. I hope you're joking :-S The issue of them not building by default wasn't that they might not build, just

Re: [sqlalchemy] c-extensions have to be explicitly requested?!

2010-07-08 Thread Chris Withers
Michael Bayer wrote: Not sure if we'd want to change this default midway through 0.6 or wait til 0.7. Fair enough, but this is sadly one of those things where you're only likely to find the edge cases when you do make it on by default... The C exts also don't improve performance that much

[sqlalchemy] mapping objects to arbitary selects, read and write

2010-07-08 Thread Chris Withers
Hi All, Say we have the following model: class Price(Base): __tablename__ = 'price' id = Column(Integer, primary_key=True) value = Column(Numeric(precision=36, scale=12)) class Instrument(Base): __tablename__ = 'instrument' id = Column(Integer, primary_key=True) ticker

Re: [sqlalchemy] mapping objects to arbitary selects, read and write

2010-07-08 Thread Chris Withers
Michael Bayer wrote: class Allocation(Base): __tablename__ = 'data' id = Column(Integer, primary_key=True) trade_id = Column(Integer, index=True) instrument_id = Column(ForeignKey(Instrument.id)) instrument = relationship(Instrument) quantity = Column(Integer) price_id =

[sqlalchemy] sqlalchemy-migrate examples

2010-08-18 Thread Chris Withers
Hi All, Does anyone have any good examples of migration scripts? The documentation is surprisingly sparse.. Of course, an alernative which doesn't do any abusive monkey patching or have any annoying * imports would be handy. Michael, how's Alembic coming? Chris -- You received this message

Re: [sqlalchemy] Which columns changing during orm commit?

2010-08-19 Thread Chris Withers
Michael Hipp wrote: SQLAlchemy seems pretty smart about updating only the changed columns in an orm object... If I have an orm object. Something changes one of the columns. Just before I commit() the session, is there a way to tell which columns will be updated vs those that are unchanged?

Re: [sqlalchemy] Re: negative implications of using multiple declarative Base classes

2010-08-24 Thread Chris Withers
avdd wrote: I'm glad you brought this up. It seems to me that the the declarative instrumentation keys classes by their unqualified class name, precluding using the same class name for different declarative subclasses (ie, in different modules). Indeed, but I suspect there's more to it than

Re: [sqlalchemy] Support for CouchDB

2010-08-25 Thread Chris Withers
Michael Bayer wrote: There's a long term plan to allow plugins that would provide attribute instrumentation and Session persistence services to objects that are persisted by a non-SQL database. I guess at this point you'd need to drop 'SQL' from 'SQLAlchemy' ;-) Chris -- Simplistix -

[sqlalchemy] reflected column spec doesn't match model column spec

2010-08-26 Thread Chris Withers
Hi All, For the following model: class Header(Base): __tablename__ = 'header' id = Column(Integer, primary_key=True) message_id = Column(Integer,ForeignKey('message.id')) name = Column(String(50)) value = Column(Text(255)) sqlalchemy-migrate's SchemaDiff tool against the

Re: [sqlalchemy] reflected column spec doesn't match model column spec

2010-08-26 Thread Chris Withers
Michael Bayer wrote: How can it be changed so that the column reflected from the DB and the column calculated from the model end up being the same? if schemas are being diffed, types can be compared generically using type affinity. This is described at:

[sqlalchemy] hierarchical data storage and searching

2010-09-08 Thread Chris Withers
Hi All, I'm trying to solve a hierarchical access control problem, both on the storage and querying side. So, say I have a tree of content: / /a/ /a/1 /a/2 /b/ /b/1 /b/2 I want to be able to express and search on the following types of requirements: User X should be able to access all

Re: [sqlalchemy] Re: hierarchical data storage and searching

2010-09-09 Thread Chris Withers
On 08/09/2010 19:23, Gunnlaugur Briem wrote: http://communities.bmc.com/communities/docs/DOC-9902 Thanks for all of the references, but this one in particular. Materialized paths looks like its the closest to what I'm after. However, with materialized paths, I'm wondering with a structure

Re: [sqlalchemy] Re: hierarchical data storage and searching

2010-09-09 Thread Chris Withers
Conor wrote: SELECT EXISTS (SELECT 1 FROM access_control WHERE (path = '/a' OR path LIKE '/a/%') AND user = :user AND permission = :permission) Most materialized path queries use LIKE a lot. As long as you keep the % character at the end, a good DB will be able to use an index to speed up

[sqlalchemy] paranoia - does flush ensure a unique id?

2010-09-13 Thread Chris Withers
Hi All, Give the following model: from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.types import Integer Base = declarative_base() class Model(Base): __tablename__='test' id = Column(Integer, primary_key=True) col = Column(Integer) ...the following code will

Re: [sqlalchemy] internationalization of content

2010-09-14 Thread Chris Withers
On 13/09/2010 22:37, NiL wrote: Has anyone tried ti implement this ? a working solution ? willing to participate in a effort to provide a solution ? Isn't this something better suited to the application framework rather than the database framework (ie: not SQLAlchemy)? cheers, Chris --

Re: [sqlalchemy] paranoia - does flush ensure a unique id?

2010-09-14 Thread Chris Withers
On 13/09/2010 18:02, Chris Withers wrote: What ensures obj.id will be unique and will it always be unique, even in the case of high volumes of parallel writes to the database? Does it depend on the back end? Are any backends known not to work this way? In short, the unique constrant

Re: [sqlalchemy] Declarative classproperty member problem in 0.6.4, not 0.6.3

2010-09-15 Thread Chris Withers
On 15/09/2010 15:04, Nikolaj wrote: Base = declarative_base() class Person(Base): __tablename__ = 'people' name = Column(String, primary_key=True) @classproperty def bar(cls): return cls.foo Can you explain why you'd want to do something like this? Chris --

Re: [sqlalchemy] Re: Fetching last insert id from MySQL.

2010-09-16 Thread Chris Withers
On 16/09/2010 11:49, phasma wrote: session imported from Meta ? If use Meta.Session.execute it's returns RowProxy, which has no lastrowid parameter. Try this: with meta.Session: result = meta.Session.execute(INSERT statement) print result.lastrowid cheers, Chris -- Simplistix -

[sqlalchemy] semantics of tometadata

2010-09-16 Thread Chris Withers
Hi All, As part of looking into #1919, I see that if a table of the same name as the one passed to tometadata already exists in the destination metadata, then the table object passed in is ignored and the one already there is returned. That feels wrong to me. In the event there's already a

Re: [sqlalchemy] semantics of tometadata

2010-09-16 Thread Chris Withers
On 16/09/2010 20:26, Michael Bayer wrote: As such, I'd expect an exception to be raised rather than the other table object being returned. What do people feel about this? Im fine with tometadata raising for 0.7. a warning for 0.6 perhaps. Cool, done for 0.6. Where should I make the

[sqlalchemy] allow Index to take column names as well as columns?

2010-09-21 Thread Chris Withers
Hi All, I'm wondering if there's a reason why Index doesn't play the sames that ColumnCollectionConstraint does to allow columns names instead of column objects to be parsed? Why? Well, 'cos I'd like to do: from sqlalchemy import * metadata = MetaData() mytable = Table('user', metadata,

Re: [sqlalchemy] Batch Delete with ORM

2010-10-05 Thread Chris Withers
On 04/10/2010 13:16, Mark Erbaugh wrote: If I were doing this in SQL, I would to the first command as SELECT count(*) FROM period WHERE period.cycle = ? Why would you do this first? Chris -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post

Re: [sqlalchemy] MySQL DATE_ADD function

2010-10-05 Thread Chris Withers
On 04/10/2010 22:53, Bryan wrote: I'm having trouble converting this SQL into an ORM statement. DATE_ADD(datecol, INTERVAL(1 - DAYOFWEEK(datecol)) DAY) This is as far as I can get, which is basically nowhere. The second argument to date_add requires literal strings INTERVAL and DAY, but I

  1   2   3   4   5   >