[sqlalchemy] Re: append to children in hierarchical data

2012-04-12 Thread lars van gemerden
The question was based on a misconception on my part (in a visual representation of a tree, while dragging a node you drag the whole subtree with it, so you can't drop a node in it's own subtree). Sorry about that ... PS: Checked that when updating the children (via append) the exception

[sqlalchemy] Re: query with one attribute of table to list

2012-04-12 Thread lestat
Maybe in sqlalchemy add attribute like flat=True that return list with values (instead of tuples with values) ? вторник, 27 марта 2012 г., 19:27:04 UTC+4 пользователь lestat написал: If I want get list of id's of table I can get it with z = db.session.query(MyTable.id).all() but it return

[sqlalchemy] About alembic alter column problem

2012-04-12 Thread limodou
I'm using alembic today, and I found a problem, if I changed the column, it'll automatically create add and drop statment, just like this: op.add_column('bas_grp_user', sa.Column('username', sa.Integer(), nullable=False)) op.drop_column('bas_grp_user', u'USERNAME') But when I ran the

[sqlalchemy] Re: About alembic alter column problem

2012-04-12 Thread limodou
I also have other requirements: 1. if there is no changes should it can create nothing, not like this: def upgrade(): ### commands auto generated by Alembic - please adjust! ### pass ### end Alembic commands ### def downgrade(): ### commands auto generated by Alembic - please

[sqlalchemy] Re: Weird exception between dev prod

2012-04-12 Thread Derek Litz
Based on the error message I would guess this is a problem with your install of Microsoft's SQL Native Client for odbc. Sorry, not a windows guy, so all I can provide is a link http://msdn.microsoft.com/en-us/library/ms131321.aspx. Is your dev MS native client the same as the prod MS native

Re: [sqlalchemy] Re: append to children in hierarchical data

2012-04-12 Thread Michael Bayer
Probably autoflush when you hit .children - you'd see it in the stack trace Sent from my iPhone On Apr 12, 2012, at 3:47 AM, lars van gemerden l...@rational-it.com wrote: The question was based on a misconception on my part (in a visual representation of a tree, while dragging a node you

Re: [sqlalchemy] About alembic alter column problem

2012-04-12 Thread Michael Bayer
On Apr 12, 2012, at 4:07 AM, limodou wrote: I'm using alembic today, and I found a problem, if I changed the column, it'll automatically create add and drop statment, just like this: op.add_column('bas_grp_user', sa.Column('username', sa.Integer(), nullable=False))

Re: [sqlalchemy] Re: About alembic alter column problem

2012-04-12 Thread Michael Bayer
On Apr 12, 2012, at 4:18 AM, limodou wrote: I also have other requirements: 1. if there is no changes should it can create nothing, not like this: def upgrade(): ### commands auto generated by Alembic - please adjust! ### pass ### end Alembic commands ### def downgrade():

Re: [sqlalchemy] About alembic alter column problem

2012-04-12 Thread limodou
On Thu, Apr 12, 2012 at 10:37 PM, Michael Bayer mike...@zzzcomputing.com wrote: On Apr 12, 2012, at 4:07 AM, limodou wrote: I'm using alembic today, and I found a problem, if I changed the column, it'll automatically create add and drop statment, just like this:    

Re: [sqlalchemy] Re: About alembic alter column problem

2012-04-12 Thread limodou
On Thu, Apr 12, 2012 at 10:39 PM, Michael Bayer mike...@zzzcomputing.com wrote: On Apr 12, 2012, at 4:18 AM, limodou wrote: I also have other requirements: 1. if there is no changes should it can create nothing, not like this: def upgrade():    ### commands auto generated by Alembic -

Re: [sqlalchemy] Re: About alembic alter column problem

2012-04-12 Thread limodou
2. If I can merge the current changes into head revision, before I execute upgrade, so that I can combine several changes into one change. For me, I think just remove the head revision, and recreate new one that's ok. And only problem I think is that : if the user has manually changed the

Re: [sqlalchemy] About alembic alter column problem

2012-04-12 Thread Michael Bayer
On Apr 12, 2012, at 10:42 AM, limodou wrote: On Thu, Apr 12, 2012 at 10:37 PM, Michael Bayer mike...@zzzcomputing.com wrote: On Apr 12, 2012, at 4:07 AM, limodou wrote: I'm using alembic today, and I found a problem, if I changed the column, it'll automatically create add and drop

Re: [sqlalchemy] Re: About alembic alter column problem

2012-04-12 Thread Michael Bayer
On Apr 12, 2012, at 10:50 AM, limodou wrote: On Thu, Apr 12, 2012 at 10:39 PM, Michael Bayer mike...@zzzcomputing.com wrote: On Apr 12, 2012, at 4:18 AM, limodou wrote: I also have other requirements: 1. if there is no changes should it can create nothing, not like this: def

Re: [sqlalchemy] Re: About alembic alter column problem

2012-04-12 Thread Michael Bayer
On Apr 12, 2012, at 10:54 AM, limodou wrote: 2. If I can merge the current changes into head revision, before I execute upgrade, so that I can combine several changes into one change. For me, I think just remove the head revision, and recreate new one that's ok. And only problem I think is

[sqlalchemy] possible bug about new Engine transaction's context manager

2012-04-12 Thread Manlio Perillo
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi. I looked at SQLAlchemy source code to see examples about `with` statement support and found something that look suspicious to me. class Engine: def begin(self, close_with_result=False) conn = self.contextual_connect(

[sqlalchemy] query vs select

2012-04-12 Thread jo
Hi all, I'm sorry for this simple question. What's the difference between query and select ? are they interchangeable? which of the two, it is best to use? --- print(session.query(Azienda.c.data_inizio).limit(1)) SELECT azienda_data_inizio FROM (SELECT azienda.data_inizio AS

Re: [sqlalchemy] possible bug about new Engine transaction's context manager

2012-04-12 Thread Michael Bayer
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Apr 12, 2012, at 1:55 PM, Manlio Perillo wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi. I looked at SQLAlchemy source code to see examples about `with` statement support and found something that look suspicious to me. class

Re: [sqlalchemy] query vs select

2012-04-12 Thread Michael Bayer
There's some degree of history here as SQLAlchemy initially didn't have the whole generative notion of things, and the Mapper object itself would accept arguments which it passed mostly straight to a select() object. So you saw similar interfaces and it was kind of like switching between

Re: [sqlalchemy] About alembic alter column problem

2012-04-12 Thread limodou
On Thu, Apr 12, 2012 at 11:38 PM, Michael Bayer mike...@zzzcomputing.com wrote: On Apr 12, 2012, at 10:42 AM, limodou wrote: On Thu, Apr 12, 2012 at 10:37 PM, Michael Bayer mike...@zzzcomputing.com wrote: On Apr 12, 2012, at 4:07 AM, limodou wrote: I'm using alembic today, and I found a

Re: [sqlalchemy] Re: About alembic alter column problem

2012-04-12 Thread limodou
On Thu, Apr 12, 2012 at 11:52 PM, Michael Bayer mike...@zzzcomputing.com wrote: On Apr 12, 2012, at 10:50 AM, limodou wrote: On Thu, Apr 12, 2012 at 10:39 PM, Michael Bayer mike...@zzzcomputing.com wrote: On Apr 12, 2012, at 4:18 AM, limodou wrote: I also have other requirements: 1.

Re: [sqlalchemy] Re: About alembic alter column problem

2012-04-12 Thread limodou
On Thu, Apr 12, 2012 at 11:59 PM, Michael Bayer mike...@zzzcomputing.com wrote: On Apr 12, 2012, at 10:54 AM, limodou wrote: 2. If I can merge the current changes into head revision, before I execute upgrade, so that I can combine several changes into one change. For me, I think just remove

Re: [sqlalchemy] Re: About alembic alter column problem

2012-04-12 Thread Michael Bayer
On Apr 12, 2012, at 8:07 PM, limodou wrote: For example, in my case, when I made some changes and I want to test them, so I can run revision --autogenerate and upgrade the database. And then I made other changes, and do the cycle again I can do this way. But sometimes I just change the

Re: [sqlalchemy] Re: About alembic alter column problem

2012-04-12 Thread limodou
On Fri, Apr 13, 2012 at 8:48 AM, Michael Bayer mike...@zzzcomputing.com wrote: On Apr 12, 2012, at 8:07 PM, limodou wrote: For example, in my case, when I made some changes and I want to test them, so I can run revision --autogenerate and upgrade the database. And then I made other changes,

Re: [sqlalchemy] query vs select

2012-04-12 Thread jo
Thanks Michael, your explanation is comprehensive, currently I'm using both of them, but I feared that one of them could become obsolete in the future. I'm trying to translate some queries that I had done with engine but I find it hard to do. For example, a query like this one, I can not set it