[sqlalchemy] stucco_evolution 0.4 released
stucco_evolution 0.4 has been released. It is a migration tool for SQLAlchemy that attempts to deal with packaged dependencies having their own migration scripts. Reading - as depends on, web application - openid package - users/groups package web application - users/groups package When asked to upgrade web application, stucco_evolution will topologically sort its dependencies, run all the migrations for the users/groups package, then run the migrations for the openid package, and finally run the migrations for the web application. If the dependency migrations are constrained in what they change, it works. Foreign key relationships can point in the direction of the - without problems. Let me know if you've tried it, or know of another package that attempts to deal with non-monolithic database migration. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/D_bztOahVBQJ. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
Re: [sqlalchemy] stucco_evolution 0.4 released
On Thursday, April 19, 2012 1:43:59 PM UTC-4, Michael Bayer wrote: If you've seen my recent talks you saw that I'm a little skeptical of what you're terming non-monolithic databases.Let's say this means, a database with a set of tables maintained by entirely different packages, but with the possibility of dependencies between those tables.If I understand correctly, if we were dealing with sets of tables that didn't have any dependency, you wouldn't need a distributed migration tool, each package would handle migrations for its own set of tables independently, is that right ? I think what I need to see here are, what exactly are these packages, outside of the Django community, that actually create their own tables yet encourage dependencies between those tables and your app's own tables ? I know people are working on them since I see people asking questions about those use cases, but what are they ? What's the openid and user/groups package you're thinking of here ? I think you are right, there isn't anything outside of the Django world that does this; stucco_evolution is my attempt to bring something like that kind of re-use to my non-Django-powered world, and as far as I can tell*, I am its only user. * Koders code search Admittedly so far the only use case is the users/groups schema where the application attaches a separate user profile table, just like Django. The relationships always go in only one direction: the dependent schema holds a foreign key referencing the dependency schema. It really is possible to distribute the entire user management interface as a separately maintained package, while still being able to get at user.profile in your app, but you won't be able to perform migrations that change the user table's primary key. It's probably more useful that stucco_evolution makes sure the users table is simply created first. In the openid case, an openid package manages a users_openids table instead of adding an openid column to the users table. So there you have it. It very well may be that there is exactly one use case for this package, but who doesn't need to keep track of users and groups? Other than that it does a passable job of applying hand-written linear database upgrades, and it is short. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/AQejNE70FEYJ. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
Re: [sqlalchemy] stucco_evolution 0.4 released
So there you have it. It very well may be that there is exactly one use case for this package, but who doesn't need to keep track of users and groups? Other than that it does a passable job of applying hand-written linear database upgrades, and it is short. that it is, and the surprise here isrepoze.evolution ! yikes ! so I guess with these two systems, writing the scripts is totally up to the developer, is that right ? There's a lot that alembic could bring into this. There's all the Alembic ops and dialect-agnostic directives (DDL abstraction). There's migration modes that either talk directly to a database or generate a SQL Script.There's the tools to create new scripts and a more sophisticated versioning scheme too (repoze.evolution seems to use an incrementing integer). It almost seems like Alembic could integrate with repoze.evolution though I'm not sure if that's useful. You could certainly use Alembic's DDL abstractions directly in this system with a couple of lines if nothing else? My little project doesn't care about DDL, it just passes your script a connection. I didn't consider Alembic when I wrote stucco_evolution in 2010 but I wouldn't mind using it now. At the time I just needed something that didn't scare me. repoze.evolution is fine, it is only 98 lines of code, 17 of which I actually execute. Its design abstracts out the kind of thing that is being upgraded, so you could write another kind of EvolutionManager() to upgrade filesystems if you felt like it. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/25sv7PEmPy8J. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] Re: Query results not Integers
The query is simply returning rows with one column. For example session.query(X.a, X.b).all() would return a potentially less surprising list rows with two columns. The rows can be indexed by name or number. The 'L' is just Python telling you it is a long integer. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
Re: [sqlalchemy] sqlite transaction isolation, select for update, race condition
Is this pysqlite issue about SELECT not starting a transaction related? http://code.google.com/p/pysqlite/issues/detail?id=21 -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
Re: [sqlalchemy] Re: replacing or altering a mapper?
I suppose you explicitly don't want to call User.morestuff.otherproperty? I like doing it that way, but it could be that I am underusing SQLAlchemy's inheritance features. The following works fine: package 1: Base1 = declarative_base() class User(Base1): pass package 2: Base2 = declarative_base() class MoreUserStuff(Base2): user_id = Column(Integer, ForeignKey(User.user_id), index=True)user = relationship(User, backref='morestuff') -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] Re: Migrating from 0.4.8 (yes 0.4.8)
You should expect better ORM performance in newer versions. You should go straight to 0.6 and see what happens, with an eye on the 0.5 and 0.6 release notes for the things that most people have to change (it shouldn't be a big deal). RunSnakeRun is supposed to be a nifty profiler. Can you profile unit/integration tests for only the Python portion of the code to bypass the PyObjC bridge? -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] stucco_evolution 0.33 released!
stucco_evolution is my entry into the crowded 'schema migration' space. For people that like writing their own ALTER TABLE statements, stucco_evolution only concerns itself with passing a SQLAlchemy connection to numbered Python scripts in an evolve/ package, maintaining a (name, number) tuple for each managed package. stucco_evolution is 200 lines of code with automated tests that provide 100% statement coverage. It works well for me, but the functions in the API do not have very good names. Suggestions welcome. Daniel Holth -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
Re: [sqlalchemy] Transactional DDL and SQLite?
Thanks Mike. I will have to edit the pysqlite C source code if I want to prevent it from committing when the query does not contain any of the strings select, insert, update, delete, or replace. if (!strcmp(buf, select)) { return STATEMENT_SELECT; } else if (!strcmp(buf, insert)) { return STATEMENT_INSERT; } else if (!strcmp(buf, update)) { return STATEMENT_UPDATE; } else if (!strcmp(buf, delete)) { return STATEMENT_DELETE; } else if (!strcmp(buf, replace)) { return STATEMENT_REPLACE; } else { return STATEMENT_OTHER; } -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
Re: [sqlalchemy] Transactional DDL and SQLite?
It looks like SQLAlchemy 0.7's events make it a lot easer to prepend /* select */ to every statement. Daniel -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
Re: [sqlalchemy] Transactional DDL and SQLite?
I thought I could prepend /* update * / to every statement but that didn't work. Instead, https://bitbucket.org/dholth/pysqlite/changeset/cdc3a85dcb49 Obviously it should be a flag. Something like pysqlite2.surprise_transactions(False) -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] Transactional DDL and SQLite?
Can someone help me understand why DDL seems to not be transactional here: import sqlalchemy e = sqlalchemy.create_engine('sqlite://') c = e.connect() t = c.begin() c.execute(CREATE TABLE foo (bar INTEGER)) t.rollback() assert u'foo' in e.table_names() # True But, if I start up `sqlite3 db.db` and type: BEGIN; CREATE TABLE foo (bar INTEGER); ROLLBACK; then no `foo` table is created. I am using SQLite 3.7.2. I am trying to write migration scripts that create a table and populate it, or fail and rollback the entire transaction. Thanks. -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] Re: can some one give me sample on using max with session.query?
session.query(sqlalchemy.func.max(MappedClass.column)).scalar() -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] Re: autocommit on for DDL
You might be interested to know that the situation is more like If you are not using MySQL, you probably have transactional DDL. Even SQLite has it. According to http://wiki.postgresql.org/wiki/Transactional_DDL_in_PostgreSQL:_A_Competitive_Analysis - PostgreSQL - yes - MySQL - no; DDL causes an implicit commit - Oracle Database 11g Release 2 and above - yes (something called edition-based redefinition) - Older versions of Oracle - no; DDL causes an implicit commit - SQL Server - yes - Sybase Adaptive Server - yes - DB2 - yes - Informix - yes - Firebird (Interbase) - yes -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] subclass mapped class to add utility methods?
I am trying to subclass a mapped class from another package for no other reason than to add a utility method. The polymorphic_on condition, if it were defined, would have to be 'True'. Example: class Mapped(declarative_base()): # columns class Utility(Mapped): def is_something(self): return 'foo' Encouraged by the fact that session.query(Utility).first() works, I proceeded and got an exception. The error is FlushError: Attempting to flush an item of type Utility on collection 'Something.mapped', which is not the expected type. Configure mapper 'Mapper|User|user' to load this subtype polymorphically, or set enable_typechecks=False to allow subtypes. Mismatched typeloading may cause bi-directional relationships (backrefs) to not function properly. I'm starting to think I should just monkey patch the original class or just pass the Mapped() into utility()... is that the best way? Thanks! Daniel -- 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 sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] Re: subclass mapped class to add utility methods?
Thank you! I never would have thought of appending a superclass as an alternative to subclassing or monkeypatching. No wonder Python is so hard to optimize. I wound up doing the monkey patch and it seems to work just fine. -- 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 sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] Re: nested transactions with zope extension
On Dec 21, 6:27 pm, gizli mehm...@gmail.com wrote: Hi all, This is only for people who use the zope extension for SA (http:// pypi.python.org/pypi/zope.sqlalchemy). Consider the following: for task in conn.query(Task): conn.begin_nested() try: conn.delete(task) conn.commit() except Exception: conn.rollback() conn.commit() I noticed that when I use the zope extension and the transaction manager, I have to code this differently to do the same thing. Most noticeably, I cannot have a commit inside the for loop anymore (which closes/discards the save-point). The reason is that transaction.commit () automatically discards all nested save-points and commits the entire transaction. So, I need to do something like this: for task in conn.query(Task): conn.begin_nested() try: conn.delete(task) except Exception: conn.rollback() transaction.commit() Is this acceptable and expected? It just seems wrong to begin nested transactions this way. conn.commit() is strictly forbidden by the zope extension. May be the zope extension should allow commits if they are discarding a savepoint rather than actually doing a commit? Or may be SA should have a conn.end_nested() rather than commit? Right now, the terminology is confusing (when I first saw the first piece of code, I thought the loop was committing the changes at each iteration). Could you please shed some light on this situation? Thanks. Take a look at transaction.savepoint(). It looks like it may only support rolling back (not committing) savepoints. http://svn.zope.org/repos/main/zope.sqlalchemy/trunk/src/zope/sqlalchemy/ -- 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 sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] Announcing progress_sa
A SQLAlchemy dialect that can be used to read OpenEdge 10 (aka Progress) databases over ODBC. I only use it to read from the database so although it is useful it is certainly incomplete. There is enough there to make queries against reflected tables. It was remarkably easy to implement against SQLAlchemy 0.6 (svn trunk). http://pypi.python.org/pypi/progress_sa -- 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 sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
[sqlalchemy] Re: MySQL schema and character_Set_results
P.S. My application uses reflection. For MySQL it would make so much sense to combine table exists with show me the table, since they are the same request. We should cache the result. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---