[sqlalchemy] object has no attribute 'delete'

2010-04-13 Thread jo
Hi all, I'm trying migrate from 0.3 to 0.6 I don't know how to delete an object in the old version it was: My.get(1).delete() in 0.6: My.get(1).delete() AttributeError: 'My' object has no attribute 'delete' j -- Jose Soares Sferacarta Net Via Bazzanese 69 40033 Casalecchio di Reno

[sqlalchemy] cls._state / cls._state.get('original')

2010-04-13 Thread jo
Hi all, I cannot find anymore the attribute _state : if (not cls._state or not cls._state.get('original') or (cls._state['original'].data.get(k) != data.get(k: Could someone please help me? thank you j -- You received this message because you are subscribed to the Google Groups

Re: [sqlalchemy] object has no attribute 'delete'

2010-04-13 Thread Fernando Takai
Hi, You can try: My.query.filter_by(id=id).delete() (If your object can use the .query syntax) or session.query(My).filter_by(id=id).delete() On Apr 13, 2010 6:12 AM, jo jose.soa...@sferacarta.com wrote: Hi all, I'm trying migrate from 0.3 to 0.6 I don't know how to delete an object in the

[sqlalchemy] Re: Newbie mapper question

2010-04-13 Thread Damien Tougas
Hello Connor, That worked great! Thanks for the tip, it makes sense to me now why you would do it that way. On Apr 7, 5:13 pm, Conor conor.edward.da...@gmail.com wrote: Seehttp://www.sqlalchemy.org/docs/05/mappers.html#mapping-a-class-agains... for an example for mapping to arbitrary selects.

Re: [sqlalchemy] object has no attribute 'delete'

2010-04-13 Thread jo
It works, thank you, Fernando. :-) j Fernando Takai wrote: Hi, You can try: My.query.filter_by(id=id).delete() (If your object can use the .query syntax) or session.query(My).filter_by(id=id).delete() On Apr 13, 2010 6:12 AM, jo jose.soa...@sferacarta.com mailto:jose.soa...@sferacarta.com

[sqlalchemy] Declarative mapping and inheritance

2010-04-13 Thread Eagleamon
Hi all, I'm playing around with sqlalchemy for a new project and it's really great :) ... up to now. I'm in front of a problem: let's say I have several classes: class ParameterDefinition(Base): __tablename__ = ParameterDefinitions __table_args__ = {'mysql_engine':'InnoDB'} Type =

Re: [sqlalchemy] object has no attribute 'delete'

2010-04-13 Thread Andrija Zarić
http://www.sqlalchemy.org/docs/ormtutorial.html#deleting On 13 April 2010 11:12, jo jose.soa...@sferacarta.com wrote: Hi all, I'm trying migrate from 0.3 to 0.6 I don't know how to delete an object in the old version it was: My.get(1).delete() in 0.6: My.get(1).delete()

Re: [sqlalchemy] Re: SQLite Foreign Key Enforcement

2010-04-13 Thread Michael Bayer
NickPerkins wrote: Thanks, I tried it...but could not get the desired result ( enforced FKs using SQLite ). Here is my test code: #!/usr/bin/env python import sqlalchemy from sqlalchemy.interfaces import PoolListener class MyListener(PoolListener): def connect(self, dbapi_con,

Re: [sqlalchemy] Declarative mapping and inheritance

2010-04-13 Thread Michael Bayer
Eagleamon wrote: Hi all, I'm playing around with sqlalchemy for a new project and it's really great :) ... up to now. I'm in front of a problem: let's say I have several classes: class ParameterDefinition(Base): __tablename__ = ParameterDefinitions __table_args__ =

[sqlalchemy] Is it possible to combine Query results for sorting the output?

2010-04-13 Thread Richard de Koning
I created a function where I can loop through a list of words and search for these words in a database which looks like: for instance in session.query(table).filter(or_(\ table.logtext.like(term), table.titlelog.like(term)))\ .order_by(desc(table.unixtime)): I sort the

Re: [sqlalchemy] Is it possible to combine Query results for sorting the output?

2010-04-13 Thread Conor
Richard de Koning wrote: I created a function where I can loop through a list of words and search for these words in a database which looks like: for instance in session.query(table).filter(or_(\ table.logtext.like(term), table.titlelog.like(term)))\

[sqlalchemy] Re: Is it possible to combine Query results for sorting the output?

2010-04-13 Thread Richard de Koning
Thanks Conor. It works like a charm. You gave me a lot of insight in using sqla more flexible. Up to now I'm having very long statements but your way is much more self- explanatory than my own long versions. I didn't now the yield_per. Why is it only for non-MySQL databases? On Apr 13, 8:30 pm,

Re: [sqlalchemy] Re: Is it possible to combine Query results for sorting the output?

2010-04-13 Thread Conor
Richard de Koning wrote: Thanks Conor. It works like a charm. You gave me a lot of insight in using sqla more flexible. Up to now I'm having very long statements but your way is much more self- explanatory than my own long versions. I didn't now the yield_per. Why is it only for non-MySQL

[sqlalchemy] Re: Is it possible to combine Query results for sorting the output?

2010-04-13 Thread Richard de Koning
I don't use MySQL either (only if I have to) Before I was using sqla I inserted using plain SQL and noticed that I lost a lot of inserts when bulk-importing data (up to 25% !) because MySQL couldn't handle it. Never really dug into it, but just started using Postgres (and very happy about it)

[sqlalchemy] Re: SQLite Foreign Key Enforcement

2010-04-13 Thread NickPerkins
I have confirmed that it works from the sqlite3 interactive session: sqlite insert into child values(33); Error: foreign key mismatch I will try it with pysqlite...see what happens... On Apr 13, 9:59 am, Michael Bayer mike...@zzzcomputing.com wrote: NickPerkins wrote: Thanks, I tried

[sqlalchemy] Re: SQLite Foreign Key Enforcement

2010-04-13 Thread NickPerkins
It seems that I have more than one version of SQLite installed! When I run from Python, it picks up an older version than the new one I put in the project directory. I just have to figure out which SQLite it's finding, and how to make it use the new one ( thanks for the help! ) On Apr 13,

[sqlalchemy] Re: SQLite Foreign Key Enforcement

2010-04-13 Thread NickPerkins
Solved...by replacing the sqlite3.dll in my c:\Python25\DLLS\ with a new one. On Apr 13, 6:33 pm, NickPerkins nickperkinslon...@gmail.com wrote: It seems that I have more than one version of SQLite installed! When I run from Python, it picks up an older version than the new one I put in the

[sqlalchemy] Inserting comments into SQL queries

2010-04-13 Thread George V. Reilly
I'm at the MySQL conference. A couple of speakers have recommended adding SQL comments to queries for debugging; e.g., attributing a query to a higher-level operation, or that can be parsed by a slave during replication. Is there a way to do this in SQLAlchemy? That is, the generated SQL has a /*

Re: [sqlalchemy] Inserting comments into SQL queries

2010-04-13 Thread Conor
George V. Reilly wrote: I'm at the MySQL conference. A couple of speakers have recommended adding SQL comments to queries for debugging; e.g., attributing a query to a higher-level operation, or that can be parsed by a slave during replication. Is there a way to do this in SQLAlchemy? That