Re: [sqlalchemy] Trying to walk through tutorial, getting (OperationalError) no such table

2010-09-15 Thread Roger Demetrescu
Try moving the metadata.create_all(engine) below the User class declaration. Like: snipped code class User(Base): __tablename__ = 'users' id = Column(Integer, primary_key=True) name = Column(String) fullname = Column(String) password = Column(String) def __init__(self, name,

[sqlalchemy] Re: export and import JSON from database (JSON type)

2009-02-25 Thread Roger Demetrescu
On Wed, Feb 25, 2009 at 11:39, Gregg Lind gregg.l...@gmail.com wrote: How does one create a TypeDecorator to export and import JSON to a database using SA? I did something like that recently: - from sqlalchemy import types import simplejson class

[sqlalchemy] Re: export and import JSON from database (JSON type)

2009-02-25 Thread Roger Demetrescu
] and types.TypeEngine.is_mutable(). [1] - http://www.sqlalchemy.org/docs/05/reference/sqlalchemy/types.html#sqlalchemy.types.MutableType On Wed, Feb 25, 2009 at 10:27 AM, Roger Demetrescu roger.demetre...@gmail.com wrote: On Wed, Feb 25, 2009 at 11:39, Gregg Lind gregg.l...@gmail.com wrote: How does one create

[sqlalchemy] Re: Creating Tables From Selects

2009-01-27 Thread Roger Demetrescu
On Tue, Jan 27, 2009 at 14:31, Michael Bayer mike...@zzzcomputing.com wrote: there's nothing stopping you from just executing the SQL directly. I've never actually heard of CREATE TABLE AS before, but I just checked it out and you can certainly generate the SQL programmatically from a

[sqlalchemy] Re: Pre-commit hooks

2008-05-15 Thread Roger Demetrescu
On 5/15/08, Yannick Gingras [EMAIL PROTECTED] wrote: Michael Bayer [EMAIL PROTECTED] writes: easy enough to build yourself a generic MapperExtension that scans incoming objects for a _pre_commit() method. Yeah indeed. I used this: -- class

[sqlalchemy] Re: Pre-commit hooks

2008-05-15 Thread Roger Demetrescu
On 5/15/08, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: speed wise, this is better: hasattr is implemented as getattr + try except. i would do it even: f = getattr(instance, _pre_insert, None) if f: f() Thus the func name is spelled only once - avoids stupid mistakes. Good point...

[sqlalchemy] Re: Sane rowcount

2007-12-19 Thread Roger Demetrescu
Hi Lele - On Dec 19, 2007 9:08 PM, Lele Gaifax [EMAIL PROTECTED] wrote: On Wed, 19 Dec 2007 10:21:15 -0500 Michael Bayer [EMAIL PROTECTED] wrote: sane_rowcount is set to False on FB probably because someones version of FB did not support it correctly. it might be worth tracking it

[sqlalchemy] Using invalid parameter in (un)defer functions doesn't raise exception.

2007-11-23 Thread Roger Demetrescu
Hi all, A coworker has doing some experiments with deferred column loading and noticed that SA doesn't raise any exception when defer(), undefer() or undefer_group() are called with an invalid column ou group name. In other words, if you try to follow the example from:

[sqlalchemy] Re: Using invalid parameter in (un)defer functions doesn't raise exception.

2007-11-23 Thread Roger Demetrescu
On Nov 23, 2007 2:41 PM, Michael Bayer [EMAIL PROTECTED] wrote: hey Roger - assuming this has been confirmed with version 0.4.1 you can add a trac ticket for this. I am not in front of a machine with SA installed, but my coworker told me it was 0.4.1... I'll test it at home and add a

[sqlalchemy] Re: Using invalid parameter in (un)defer functions doesn't raise exception.

2007-11-23 Thread Roger Demetrescu
hei Michael - On Nov 23, 2007 2:41 PM, Michael Bayer [EMAIL PROTECTED] wrote: hey Roger - assuming this has been confirmed with version 0.4.1 you can add a trac ticket for this. - mike It's done: #878 Cheers, Roger --~--~-~--~~~---~--~~ You received

[sqlalchemy] Re: How to get list of relations

2007-10-30 Thread Roger Demetrescu
Hei Wes and Paul... On 10/29/07, Wes Duff [EMAIL PROTECTED] wrote: Hey whats going on. I am a new sqlalchemist as well but lets see if this helps any. This is how I am getting a list of all names that corrispond with my document names class. names = [ c.name for c in

[sqlalchemy] Re: Impossible to reopen a ticket in TG's trac system

2007-10-30 Thread Roger Demetrescu
Dammit... Sent it to the wrong ML.. :-/ Sorry about the noise... Roger On 10/30/07, Roger Demetrescu [EMAIL PROTECTED] wrote: Hei guys... I have just tried to reopen a ticket, but I am getting this error: Submission rejected as potential spam (Akismet says content is spam) I

[sqlalchemy] Re: Firebird - column types

2007-10-12 Thread Roger Demetrescu
Werner, On 10/4/07, Werner F. Bruhin [EMAIL PROTECTED] wrote: Scanning firebird.py I noticed that: FBText returns BLOB SUB_TYPE 2 Shouldn't that be BLOB SUB_TYPE 1 or BLOB SUB_TYPE TEXT and FBBinary returns BLOB SUB_TYPE 1 Shouldn't that be BLOB SUB_TYPE 0 See Helen's FB Book on

[sqlalchemy] Firebird numeric types

2007-10-11 Thread Roger Demetrescu
Trying to fix the NumericTest (testtypes.py) for firebird backend, I came to this patch for FBNumeric: +def bind_processor(self, dialect): +return None + +def result_processor(self, dialect): +if self.asdecimal: +return None +else: +def

[sqlalchemy] Re: Firebird - column types

2007-10-04 Thread Roger Demetrescu
Hi Werner ! On 10/4/07, Werner F. Bruhin [EMAIL PROTECTED] wrote: Scanning firebird.py I noticed that: FBText returns BLOB SUB_TYPE 2 Shouldn't that be BLOB SUB_TYPE 1 or BLOB SUB_TYPE TEXT and FBBinary returns BLOB SUB_TYPE 1 Shouldn't that be BLOB SUB_TYPE 0 Well, I personally

[sqlalchemy] Re: aliased tables

2007-09-28 Thread Roger Demetrescu
On 9/28/07, Glauco [EMAIL PROTECTED] wrote: Yes... this is the example session.query( UnitaAziendale ).order_by(Anagrafica.c.nome) Ok... do you remember about the .join() or .outerjoin() I told you before ? That's how you should declare you Query: q = session.query( UnitaAziendale

[sqlalchemy] Re: aliased tables

2007-09-27 Thread Roger Demetrescu
Hi Glauco On 9/27/07, Glauco [EMAIL PROTECTED] wrote: Hi all, how can i know the correct name of a table compiled into qry that SA has automatically aliased? for example: a join b join c join d.. sqlalchemy has created something like select blabla from a AS anon_b406 join.

[sqlalchemy] Re: aliased tables

2007-09-27 Thread Roger Demetrescu
On 9/27/07, Glauco [EMAIL PROTECTED] wrote: If so, I think I know what you are doing wrong... you must use Query's .join() or .outerjoin() method. Like that: session.query(ObjectA).join('property_b').order_by(ObjectB.c.foobar) Where 'foobar' maps to the column from B table which you want

[sqlalchemy] Re: aliased tables

2007-09-27 Thread Roger Demetrescu
On 9/27/07, Glauco [EMAIL PROTECTED] wrote: Glauco, can you send a small test script reproducing the error ? I'll gladly take a look at that... Cheers, Roger Yes... this is the example session.query( UnitaAziendale ).order_by(Anagrafica.c.nome) SNIP Thanks Glauco... But

[sqlalchemy] Re: sqlalchemy with turbogears and assign_mapper: group_by

2007-09-10 Thread Roger Demetrescu
On 9/8/07, Lukasz Szybalski [EMAIL PROTECTED] wrote: On 9/7/07, Paul Johnston [EMAIL PROTECTED] wrote: Hi, And if I wanted to select a year and group by year? select User.Year from User group by User.Year db.execute(select([User.Year]) ??? Have a look at

[sqlalchemy] Re: Changeset 2642's fix is in the wrong place [firebird]

2007-09-10 Thread Roger Demetrescu
Michael, On 9/10/07, Michael Bayer [EMAIL PROTECTED] wrote: hey Roger - can you reopen ticket #570 and attach your patch there ? FTR, the 0.4 codebase does this differently and is probably correct over there (but also, not tested since I dont have FB). I'll do that tonight... and will

[sqlalchemy] Re: Changeset 2642's fix is in the wrong place [firebird] [PATCHES]

2007-09-10 Thread Roger Demetrescu
Michael On 9/10/07, Michael Bayer [EMAIL PROTECTED] wrote: hey Roger - can you reopen ticket #570 and attach your patch there ? FTR, the 0.4 codebase does this differently and is probably correct over there (but also, not tested since I dont have FB). I guess you meant #370.. :) Well,

[sqlalchemy] Changeset 2642's fix is in the wrong place [firebird]

2007-09-09 Thread Roger Demetrescu
Hi Michael, Do you remember this thread ? : http://tinyurl.com/2c5tzc We have recently upgraded SA from 0.3.7 (with firebird.py modified by ourself) to 0.3.10, and we got this exception: Updated rowcount 1 does not match number of objects updated 2 After some research, we found out that

[sqlalchemy] Re: Query.get with unordered multiple-column-primary-key

2007-06-13 Thread Roger Demetrescu
Hi Michael, Some of my coworkers had the same needs of Gaetan... And while I understand your solution, I figure out if SA could have it natively (detecting the presence of a dictionary)... Somethink like: query.get(dict(columnB='foo', columnA='bar') Lazy programmers are the best ones... :)

[sqlalchemy] Re: Query.get with unordered multiple-column-primary-key

2007-06-13 Thread Roger Demetrescu
On 6/13/07, Marco Mariani [EMAIL PROTECTED] wrote: Roger Demetrescu ha scritto: query.get(dict(columnB='foo', columnA='bar') Lazy programmers are the best ones... :) That's the reason lazy programmers share a superclass for all their domain objects... hint, hint :-) Yeaph, I

[sqlalchemy] Re: Query.get with unordered multiple-column-primary-key

2007-06-13 Thread Roger Demetrescu
On 6/13/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Some of my coworkers had the same needs of Gaetan... And while I understand your solution, I figure out if SA could have it natively (detecting the presence of a dictionary)... Somethink like: query.get(dict(columnB='foo',

[sqlalchemy] Re: How to run a query in an object's session/connection

2007-06-13 Thread Roger Demetrescu
On 6/13/07, kwarg [EMAIL PROTECTED] wrote: I don't explicitly create a transaction - it's all done by TG/SA behind the scenes. Take a look at this thead (the 8th message): http://tinyurl.com/39bytt Where it says: As of TG 1.0.2+ you can now get access to the SA transaction via

[sqlalchemy] Re: Firebird can't print an insert() statement

2007-05-31 Thread Roger Demetrescu
running on SUSE Linux. John On 30 May, 19:47, Roger Demetrescu [EMAIL PROTECTED] wrote: Michael, the patch did the trick... I was able to print the statement, execute it, and also do some inserts using ORM... Now the second part of my problem, which is not fixed yet... ;) here

[sqlalchemy] Firebird can't print an insert() statement

2007-05-30 Thread Roger Demetrescu
Hi Michael, I don't know when the following problem began, but anyway, I've tested it with rev.2672 and the problem persists Having this script: == from sqlalchemy import * db = create_engine(firebird://user:[EMAIL PROTECTED]//database.fdb) metadata =

[sqlalchemy] Re: Firebird can't print an insert() statement

2007-05-30 Thread Roger Demetrescu
Michael, the patch did the trick... I was able to print the statement, execute it, and also do some inserts using ORM... Now the second part of my problem, which is not fixed yet... ;) here is the script (now using default value/expression): from datetime

[sqlalchemy] News about ticket #370 ?

2007-05-25 Thread Roger Demetrescu
Hi Michael, I'm having the same problem described in ticket 370. Eg.: mapper(User, users_table, properties = dict( preferences = relation(UserPrefs, cascade=all, delete-orphan), )) when I try to do this: u = session.query(User).get(1) u.preferences.clear() session.flush() it thows a

[sqlalchemy] Re: News about ticket #370 ?

2007-05-25 Thread Roger Demetrescu
Thanks Michael, I'll give it a try at monday morning... Have a nice weekend... :) []s Roger On 5/25/07, Michael Bayer [EMAIL PROTECTED] wrote: ive turned off firebird's supports_sane_rowcount feature, update to rev 2642 for now. On May 25, 2007, at 2:43 PM, Roger Demetrescu wrote

[sqlalchemy] Column name mapping problem in 0.3.7 (firebird)

2007-05-08 Thread Roger Demetrescu
Michael, I got some errors (NoSuchColumnError) after upgrading SA from 0.3.6 to 0.3.7 After some research in mailing list history, I found this thread [1]: I modified my sqlalchemy/databases/firebird.py : --- class FBDialect(... ... def

[sqlalchemy] Re: How to survive a database restart (firebird) ?

2007-04-16 Thread Roger Demetrescu
Thanks Michael, both the 2 approaches did the trick... :) On 4/16/07, Michael Bayer [EMAIL PROTECTED] wrote: with firebird, the appropriate database closed exceptions need to be added to its dialect's is_disconnect() method...someone needs to submit a patch for that (you can create one

[sqlalchemy] Re: 'PropertyLoader' object has no attribute 'strategy'

2007-04-11 Thread Roger Demetrescu
On 4/11/07, King Simon-NFHD78 [EMAIL PROTECTED] wrote: Roger Demetrescu wrote: Do you mean using the traceback module ? I've just searched about it and I guess I should use this: try: # do my stuff except: traceback.print_exc(file=sys.stdout) raise

[sqlalchemy] Re: 'PropertyLoader' object has no attribute 'strategy'

2007-04-10 Thread Roger Demetrescu
: 'PropertyLoader' object has no attribute 'strategy' Thanks Roger On 4/11/07, Roger Demetrescu [EMAIL PROTECTED] wrote: Hi all, I have a daemon with 2 threads to control upload / download of some files (they use SQLAlchemy to find out which files must be worked). Once a week, my daemon's

[sqlalchemy] Re: Using assoc proxy with a regular field, help?

2007-02-06 Thread Roger Demetrescu
Hi iain On 2/5/07, iain duncan [EMAIL PROTECTED] wrote: Below is my code in case someone has time to look at it. At the moment it works to get article.ordering as a list instead of one field. Is there a way to tell it that this is only supposed to be one item? uselist is your friend.. :)