[sqlalchemy] Re: Can I remove a Column from the select() result set

2007-11-17 Thread Matt Culbreth

Thanks Michael.

To make a long story short, I'm appending a couple columns onto a
query, running it, and then using those two extra columns for some
client-side logic (involving calculations to be precise).  At the end
of that logic, I need to remove those two extra columns.  I'd like to
be able to do that and keep the RowProxy stuff.

There's a workaround though so it's not a big deal.  I've looked
through the code and it seems I'd be going too far outside of the core
design to keep doing this.


On Nov 17, 11:03 am, Michael Bayer [EMAIL PROTECTED] wrote:
 On Nov 17, 2007, at 12:26 AM, Matt Culbreth wrote:



  Howdy Group,

  Let's say I have a very simple query:  select person.id, person.name,
  person.age from person

  Can I remove one of the columns, say person.age, from this result
  set and still use the list as a RowProxy?  I'm trying to do it now and
  it's not working.  I'm creating a new list and appending all but the
  last (for example) columns, but it's then missing the RowProxy
  goodness.

  I realize I can do this in the original select, but I'm doing some
  client-side logic here and I need to manipulate the dataset.

 well if you use list operations etc. on the RowProxy or ResultProxy  
 youll get just a plain list (or dict, depending on what youre doing).

 within SA, we use a lot of decorator like approaches, not the python  
 @decorator thing but rather another collection class that wraps the  
 original RowProxy.

 you'd have to illustrate what you're specifically trying to do for us  
 to have some suggestions.
--~--~-~--~~~---~--~~
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] Can I remove a Column from the select() result set

2007-11-16 Thread Matt Culbreth

Howdy Group,

Let's say I have a very simple query:  select person.id, person.name,
person.age from person

Can I remove one of the columns, say person.age, from this result
set and still use the list as a RowProxy?  I'm trying to do it now and
it's not working.  I'm creating a new list and appending all but the
last (for example) columns, but it's then missing the RowProxy
goodness.

I realize I can do this in the original select, but I'm doing some
client-side logic here and I need to manipulate the dataset.

Thanks,

Matt
--~--~-~--~~~---~--~~
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] Anybody seen--Exception: invalid byte sequence for encoding UTF8?

2007-06-02 Thread Matt Culbreth

Howdy All,

I've got some existing code that I'm trying on a new server.  The code
was formerly running with Python 2.4 and SA 0.36, but this new server
is running Python 2.5 and SA 0.37.

Anyway, I've got a small program which is loading a PostgreSQL 8.2 db
from a CSV file, and I'm getting this exception:

sqlalchemy.exceptions.SQLError: (ProgrammingError) invalid byte
sequence for encoding UTF8: 0xe16e69
HINT:  This error can also happen if the byte sequence does not match
the encoding expected by the server, which is controlled by
client_encoding.

The particular (fake, generated) set of data doing this is shown
here.  It looks like that first element (city) is encoded as something
other than latin1:

{'city': 'Gu\xe1nica', 'first_name': 'Patricia', 'last_name':
'Wagner', 'zip': '25756', 'phone': '490.749.6157', 'state': 'KS',
'annual_salary': '72333', 'broker_id': 452L, 'date_hired':
datetime.date(2004, 1, 1), 'address': 'P.O. Box 815, 6723 Eget, Ave',
'commission_percentage': 0.080120064101811897}

Has anybody seen this?  Do I need to do a convert_unicode or anything
like that?

Thanks,

Matt


--~--~-~--~~~---~--~~
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: Anybody seen--Exception: invalid byte sequence for encoding UTF8?

2007-06-02 Thread Matt Culbreth

Thanks Michael, I'll do this.

When I change the model's column types to Unicode() I still get the
same type in the DB--character varying(100).  I'm assuming that's
correct?  The DB is using a UTF8 encoding.

On Jun 2, 9:53 am, Michael Bayer [EMAIL PROTECTED] wrote:
 On Jun 2, 2007, at 8:22 AM, Matt Culbreth wrote:





  Howdy All,

  I've got some existing code that I'm trying on a new server.  The code
  was formerly running with Python 2.4 and SA 0.36, but this new server
  is running Python 2.5 and SA 0.37.

  Anyway, I've got a small program which is loading a PostgreSQL 8.2 db
  from a CSV file, and I'm getting this exception:

  sqlalchemy.exceptions.SQLError: (ProgrammingError) invalid byte
  sequence for encoding UTF8: 0xe16e69
  HINT:  This error can also happen if the byte sequence does not match
  the encoding expected by the server, which is controlled by
  client_encoding.

  The particular (fake, generated) set of data doing this is shown
  here.  It looks like that first element (city) is encoded as something
  other than latin1:

  {'city': 'Gu\xe1nica', 'first_name': 'Patricia', 'last_name':
  'Wagner', 'zip': '25756', 'phone': '490.749.6157', 'state': 'KS',
  'annual_salary': '72333', 'broker_id': 452L, 'date_hired':
  datetime.date(2004, 1, 1), 'address': 'P.O. Box 815, 6723 Eget, Ave',
  'commission_percentage': 0.080120064101811897}

  Has anybody seen this?  Do I need to do a convert_unicode or anything
  like that?

 if youre parsing from the CSV file, your best bet is to parse the
 data into python unicode objects using the expected encoding of the
 filethat will detect any text in the file thats not in the
 expected encoding.  then just use the DB with convert_unicode=True
 either on create_engine() or within the individual String() types
 (String(convert_unicode=True) is now equivalent to Unicode()).


--~--~-~--~~~---~--~~
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] Asynchronous SQLAlchemy--Anybody using Twisted, sAsync?

2007-02-19 Thread Matt Culbreth

Howdy Group,

I'm playing out with a few things now and I wanted to see if anyone
else has used SQLAlchemy in an asynchronous manner?  For example, you
could create a service which responded to asynchronous requests for
data, and could be used by a web client, desktop client, other types
of clients, etc.

The sAsync project at http://foss.eepatents.com/sAsync/ seems ideally
suited for this but I haven't seen any comments about it here.

Thanks,

Matt


--~--~-~--~~~---~--~~
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] How to determine if an instance has been populated?

2007-02-12 Thread Matt Culbreth

Hello Friends,

I'm working with the latest version of SQLAlchemy now and I have a
question: how do I determine if a particular mapped object instance
has been populated by the database?

The question originates because I have defined a __repr__() method on
one of my mapped objects.  It works fine if the object has been
loaded, but throws a TypeError exception until that time because one
of the statements in the __repr__() method is using an 'int' type.

I can easily handle this by checking for None of course, but is there
a more standard way people use the tool?

Thanks,

Matt


--~--~-~--~~~---~--~~
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 determine if an instance has been populated?

2007-02-12 Thread Matt Culbreth

That got it, thanks.

On Feb 12, 3:57 pm, Michael Bayer [EMAIL PROTECTED] wrote:
 check for an _instance_key attribute.

 On Feb 12, 1:52 pm, Matt Culbreth [EMAIL PROTECTED] wrote:

  Hello Friends,

  I'm working with the latest version of SQLAlchemy now and I have a
  question: how do I determine if a particular mapped object instance
  has been populated by the database?


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