[sqlalchemy] How do I do append_whereclause() using the ORM?

2006-12-18 Thread Robin Munn

Maybe this is in the documentation, but if so, I've missed it.

I'd like to do something like the stmt = users.select();
stmt.append_whereclause(...) example found in
http://www.sqlalchemy.org/docs/sqlconstruction.myt#sql_building , but
using a Query object taken from an ORM mapper via session.query(User).
Is this possible? How would I do it?

-- 
Robin Munn
[EMAIL PROTECTED]
GPG key 0x4543D577

--~--~-~--~~~---~--~~
 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
-~--~~~~--~~--~--~---



[sqlalchemy] Re: How do I do append_whereclause() using the ORM?

2006-12-18 Thread Jose Soares

Robin Munn ha scritto:
 Maybe this is in the documentation, but if so, I've missed it.

 I'd like to do something like the stmt = users.select();
 stmt.append_whereclause(...) example found in
 http://www.sqlalchemy.org/docs/sqlconstruction.myt#sql_building , but
 using a Query object taken from an ORM mapper via session.query(User).
 Is this possible? How would I do it?

   
I'm using it in this way
---
qryBoll = session.query(Bolletta)
statements = [ Bolletta.c.anno == 2006,
  Bolletta.c.sezionale == '2006-01-01'
]
statements.append(Bolletta.c.numero == 123)  
try:
boll = qryBoll.selectone_by(*boll_statements)
except InvalidRequestError:
flash('error!')
-
I hope this help you...

jo


--~--~-~--~~~---~--~~
 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
-~--~~~~--~~--~--~---



[sqlalchemy] Re: SQLAlchemy, SQLite: ordering case insensitive

2006-12-18 Thread ragnar

Ah, that explains it. Thanks for the answer


--~--~-~--~~~---~--~~
 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
-~--~~~~--~~--~--~---



[sqlalchemy] value too long for type character varying

2006-12-18 Thread ml

Hi!

Can I force SA (0.2.8) to ignore the sqlalchemy.exceptions.SQLError:
(ProgrammingError) value too long for type character varying... and
silently truncate the inserted data?

Thank you!

David


--~--~-~--~~~---~--~~
 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
-~--~~~~--~~--~--~---



[sqlalchemy] Re: value too long for type character varying

2006-12-18 Thread Michael Bayer

well theres no way to ignore a SQL error and force an operation to
succeed.  the best strategy here is to subclass the String type to do a
string truncation in the convert_bind_param() step (that or, do a
length check beforehand).


--~--~-~--~~~---~--~~
 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
-~--~~~~--~~--~--~---



[sqlalchemy] single Session, queries against multiple classes issues

2006-12-18 Thread Alan Franzoni
Hello,
I have encountered a strange behaviour within SA, but since I seem to be
making silly questions lately, I'm not attaching a full test case - I will
if a bug is suspected.


session = create_session()

#1st block
form = session.query(Formato).get_by(id=7).reparti
print form

#2nd block
ed = session.query(Editore).get_by(id=1).reparti
print ed


reparti is a property returning the list of object for a many-to-many
relationship. there're three tables ( reparti, editori, formati ) and two
association tables ( editori_reparti, formati_reparti ); they're both eager;
the three tables have their corresponding classes mapped.

Now, the matter. If I try commenting out either the first or second block, I
get the correct results. But if I run the code as written above, the second
query (this happens even switching their order) returns an empty list.

I have enabled the echo, and both queries seem to get actually executed, and
they look the same when commenting out the code and when having all the code
run.


-- 
Alan Franzoni [EMAIL PROTECTED]
-
Togli .xyz dalla mia email per contattarmi.
Remove .xyz from my address in order to contact me.
-
GPG Key Fingerprint (Key ID = FE068F3E):
5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E


--~--~-~--~~~---~--~~
 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
-~--~~~~--~~--~--~---


[sqlalchemy] Misunderstanding something with autoloading

2006-12-18 Thread Sean Davis

I have a simple test case given here:

 from sqlalchemy import *
 db = create_engine('postgres://user:[EMAIL PROTECTED]/test5')
 metadata = BoundMetaData(db)
 tb = Table('gffdata',metadata,autoload=True)

Up to this point, I think this looks like what is in the tutorial.  However, I 
get the following error when trying to autoload.

Traceback (most recent call last):
  File stdin, line 1, in module
  File build/bdist.linux-x86_64/egg/sqlalchemy/schema.py, line 143, in 
__call__
  File build/bdist.linux-x86_64/egg/sqlalchemy/engine/base.py, line 505, in 
reflecttable
  File build/bdist.linux-x86_64/egg/sqlalchemy/databases/postgres.py, line 
386, in reflecttable
TypeError: __init__() takes at most 2 arguments (3 given)

 metadata.get_engine().raw_connection
bound method Engine.raw_connection of sqlalchemy.engine.base.Engine object 
at 0x9168d0

But after I do this call, I can autoload the table without problem.

 tb = Table('gffdata',metadata,autoload=True)

And selecting, etc., works fine at this point.  What am I missing?

Thanks,
Sean

--~--~-~--~~~---~--~~
 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
-~--~~~~--~~--~--~---



[sqlalchemy] Re: how to assign values to columns of a mapper?

2006-12-18 Thread robert rottermann
Michael Bayer wrote:
 the error message indicates that there is more than one Session in
 play.  a big reason for this is that people have import
 sqlalchemy.ext.threadlocal lying around when they dont really want
 that.
   
thanks for the hint,

I do not use threadlocal in any direct way but I am using sqlsoup.
I tried to subclass sqlsoup and handle all the engine/metadata/session
handling
trough it but I still have the same error.

What I am doing is creating the engine two times. The first time I
create a database
the second time I am using the database. could this be the problem?

I am using the following method to do it:
def _checkEngine(self):
if self._connectioninfo.has_key('dbname'):
connectionstr = '%(engine)s%(user)s:%(pw)s/%(dbname)s' %
self._connectioninfo
else:
connectionstr = '%(engine)s%(user)s:%(pw)s' %
self._connectioninfo
if self._db is None:
self._dbengine = create_engine(connectionstr)
self._metadata = BoundMetaData(self._dbengine)
self._db = RedSoup(self._metadata)
self._db._metadata.engine.echo = True

After creating the database I adapt self._connectioninfo, set self._db
to None to force
and call _checkEngine().
do I have to explicitly clean/close a session or BoundMetadata?

thanks
robert
 


--~--~-~--~~~---~--~~
 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
-~--~~~~--~~--~--~---
begin:vcard
fn:robert  rottermann
n:rottermann;robert 
email;internet:[EMAIL PROTECTED]
tel;work:031 333 10 20
tel;fax:031 333 10 23
tel;home:031 333 36 03
x-mozilla-html:FALSE
version:2.1
end:vcard