[sqlalchemy] Graphs / RDF in SA

2011-01-19 Thread state
Feeling dissatisfied with the options available in the current world
of graph databases (from what I can understand here:
http://en.wikipedia.org/wiki/Graph_database) I'm starting to think
that building a SQLAlchemy layer will be the easiest way to implement
the storage and retrieval of nodes and edges most reliably (and in
system that is well supported). I'd like to be able to sort the data
at the storage level and along with the basic standards outlined in
the RDF spec I'd like to be able to define multiple edge properties.
I'm happy to keep the storage to UTF-8 and leave the rest of it in the
filesystem, so the storage systems supported by SA are perfectly fine.

I like the efforts that went in to RDFAlchemy (http://www.openvest.com/
trac/wiki/RDFAlchemy), but judging by the look of the Google group the
project is basically dead. I've seen the graph theoretic examples
included with the SQLAlchemy documentation, but is there anything I'm
missing? It looks like discussions of this nature have come up on the
list from time to time in the past few years: so perhaps someone wants
to tell me I'm simply looking in the wrong place?

All input is appreciated. Thanks!

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] Re: INSERT RETURNING question

2011-01-19 Thread Michael Bayer

On Jan 19, 2011, at 2:54 AM, Eric Lemoine wrote:

 On Tue, Jan 18, 2011 at 11:33 PM, Michael Bayer
 mike...@zzzcomputing.com wrote:
 
 On Jan 18, 2011, at 4:47 PM, Eric Lemoine wrote:
 
 On Tuesday, January 18, 2011, Eric Lemoine eric.lemo...@camptocamp.com 
 wrote:
 Hi
 
 Probably a very simple question. I use the ORM for inserts, with
 postgres 8.3. How can I get the ids resulting from my inserts'
 RETURNING clauses? I haven't been able to find the information in the
 doc.
 
 Doing just_inserted_obj.id causes a SELECT ... WHERE id= query,
 which I'd like to avoid.
 
 That sounds like you're calling commit() which is expiring all data, 
 resulting in a re-fetch when you hit .id.  Just call session.flush(), then 
 get the .id from your objects, before a commit() occurs.
 
 I did not expect that obj.id (the primary key) would be expired, as
 doing SELECT id WHERE id= didn't make sense to me.

well the row could have been moved/deleted so thats why PK columns are part of 
that check.   (we of course have the identity of the object stored as well, 
that is separate from the primary key attributes...since they can diverge in 
this case).




 
 Thanks.
 
 
 -- 
 Eric Lemoine
 
 Camptocamp France SAS
 Savoie Technolac, BP 352
 73377 Le Bourget du Lac, Cedex
 
 Tel : 00 33 4 79 44 44 96
 Mail : eric.lemo...@camptocamp.com
 http://www.camptocamp.com
 
 -- 
 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 
 sqlalchemy+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/sqlalchemy?hl=en.
 

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



[sqlalchemy] Re: I need a final push

2011-01-19 Thread F.A.Pinkse

HEllo Michael,

Thanks for your answer.

I tried  order_by(func.monthfrom(datetime(2000, 1, 2, 0, 0, 0)))
but get the error:

global name func not defined.

I guess something must be put in front of it.


Any idea before I dig in.


My app works with Elixir.


Tnaks.


Frans.

--
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



[sqlalchemy] Re: Writing values to Postgresql type Float

2011-01-19 Thread wilbur
Thanks for responding,

I am using Postgresql 8.3.8 and Postgis 1.4. I have tried using both
DOUBLE_PRECISION and DOUBLE_PRECISION(asdecimal=True), with the same
errors.

thanks

On Jan 18, 3:50 pm, Michael Bayer mike...@zzzcomputing.com wrote:
 Here's a tested example of DOUBLE_PRECISION using both float and Decimal 
 versions.  Make sure you're on a recent release of psycopg2:

 from sqlalchemy import Column, create_engine, Integer
 from sqlalchemy.orm import Session
 from sqlalchemy.ext.declarative import declarative_base
 from sqlalchemy.dialects.postgresql import DOUBLE_PRECISION
 from decimal import Decimal

 Base = declarative_base()

 class dream4_eta_15km_pm10(Base):
    __tablename__='pm10_dream_rasters'

    id = Column(Integer, primary_key=True)

    # use float values
    max_pm10=Column(DOUBLE_PRECISION)

    # use Decimal values
    mean_pm10=Column(DOUBLE_PRECISION(asdecimal=True))

    def __repr__(self):
        return dream4_eta_15km_pm10(%r, %r) % (self.max_pm10, self.mean_pm10)

 engine = create_engine('postgresql://scott:tiger@localhost/test', echo=True)

 Base.metadata.create_all(engine)

 sess = Session(engine)

 sess.add(dream4_eta_15km_pm10(max_pm10=76945.283959, 
 mean_pm10=Decimal(7683.27835)))

 sess.commit()

 print sess.query(dream4_eta_15km_pm10).all()

 On Jan 18, 2011, at 3:24 PM, wilbur wrote:

  Hello,

  I am having problems using sqlalchemy to write values to Postgresq
  columns of type Float. I am getting sqlalchemy.exc.ProgrammingError:
  (ProgrammingError) can't adapt errors when I try to insert records.

  My Postgresql table is defined as:

      Column     |              Type
  |                            Modifiers
  +
  +--
  max_pm25       | double precision               |
  mean_pm25      | double precision               |

  After importing the Postgresql dialect:

  from sqlalchemy.dialects.postgresql import *

  I define my sqlalchemy table as:

  class dream4_eta_15km_pm10(Base):
     __tablename__='pm10_dream_rasters'
     max_pm10=Column(DOUBLE_PRECISION)
     mean_pm10=Column(DOUBLE_PRECISION)

  Any help appreciated,

  Bill

  --
  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 
  sqlalchemy+unsubscr...@googlegroups.com.
  For more options, visit this group 
  athttp://groups.google.com/group/sqlalchemy?hl=en.

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] Re: Writing values to Postgresql type Float

2011-01-19 Thread Michael Bayer
I am assuming you ran the script that I sent previously, and it produced the 
same errors.If this is not the case, please run that script.  If it runs 
without errors, then the solution is to ensure your program is passing 
numerical values in the identical fashion as the test script, and that your 
table was created in postgresql using DOUBLE PRECISION as the data type.

Assuming you ran the script I gave you and it produces the same errors, here is 
a psycopg2 script.  Run it on your environment - if it fails, please report the 
issue to the psycopg2 list, including psycopg2 and postgresql version 
information, at:  
http://mail.postgresql.org/mj/mj_wwwusr/domain=postgresql.org?func=lists-long-fullextra=psycopg

import psycopg2

conn = psycopg2.connect(user='scott', password='tiger', host='localhost', 
database='test')

cursor = conn.cursor()
cursor.execute(
CREATE TABLE double_prec_test (
double_value DOUBLE PRECISION
)
)

cursor.execute(INSERT INTO double_prec_test VALUES (%(value)s), 
{'value':7684.4933})

cursor.execute(SELECT * FROM double_prec_test)

print cursor.fetchall()

cursor.close()
conn.close()


On Jan 19, 2011, at 12:11 PM, wilbur wrote:

 Thanks for responding,
 
 I am using Postgresql 8.3.8 and Postgis 1.4. I have tried using both
 DOUBLE_PRECISION and DOUBLE_PRECISION(asdecimal=True), with the same
 errors.
 
 thanks
 
 On Jan 18, 3:50 pm, Michael Bayer mike...@zzzcomputing.com wrote:
 Here's a tested example of DOUBLE_PRECISION using both float and Decimal 
 versions.  Make sure you're on a recent release of psycopg2:
 
 from sqlalchemy import Column, create_engine, Integer
 from sqlalchemy.orm import Session
 from sqlalchemy.ext.declarative import declarative_base
 from sqlalchemy.dialects.postgresql import DOUBLE_PRECISION
 from decimal import Decimal
 
 Base = declarative_base()
 
 class dream4_eta_15km_pm10(Base):
__tablename__='pm10_dream_rasters'
 
id = Column(Integer, primary_key=True)
 
# use float values
max_pm10=Column(DOUBLE_PRECISION)
 
# use Decimal values
mean_pm10=Column(DOUBLE_PRECISION(asdecimal=True))
 
def __repr__(self):
return dream4_eta_15km_pm10(%r, %r) % (self.max_pm10, 
 self.mean_pm10)
 
 engine = create_engine('postgresql://scott:tiger@localhost/test', echo=True)
 
 Base.metadata.create_all(engine)
 
 sess = Session(engine)
 
 sess.add(dream4_eta_15km_pm10(max_pm10=76945.283959, 
 mean_pm10=Decimal(7683.27835)))
 
 sess.commit()
 
 print sess.query(dream4_eta_15km_pm10).all()
 
 On Jan 18, 2011, at 3:24 PM, wilbur wrote:
 
 Hello,
 
 I am having problems using sqlalchemy to write values to Postgresq
 columns of type Float. I am getting sqlalchemy.exc.ProgrammingError:
 (ProgrammingError) can't adapt errors when I try to insert records.
 
 My Postgresql table is defined as:
 
 Column |  Type
 |Modifiers
 +
 +--
 max_pm25   | double precision   |
 mean_pm25  | double precision   |
 
 After importing the Postgresql dialect:
 
 from sqlalchemy.dialects.postgresql import *
 
 I define my sqlalchemy table as:
 
 class dream4_eta_15km_pm10(Base):
__tablename__='pm10_dream_rasters'
max_pm10=Column(DOUBLE_PRECISION)
mean_pm10=Column(DOUBLE_PRECISION)
 
 Any help appreciated,
 
 Bill
 
 --
 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 
 sqlalchemy+unsubscr...@googlegroups.com.
 For more options, visit this group 
 athttp://groups.google.com/group/sqlalchemy?hl=en.
 
 -- 
 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 
 sqlalchemy+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/sqlalchemy?hl=en.
 

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



[sqlalchemy] scalar association_proxy

2011-01-19 Thread AgentOrange
Hi Folks,

I have been scratching my head over this one all day, so any advice
would be greatly appreciated!

I have a pretty simple join table setup like this:

foo foo_bar  bar
---
id  id_foo (unique)  id
id_bar
more_stuff

It looks like a many-to-many relationship, but it's not, since id_foo
is unique in the join table.

- There can be any number of 'foo' for each 'bar'
- Each 'foo' has exactly one or zero 'bar'

I have set up the required declarative stuff, and an association proxy
in 'foo' to get to 'bar' in one nice step. Since there can only ever
be one (or zero - and this is my problem) I have set it to be a
scalar.

It all works great, except that if I try and look at the value of the
assoication proxy in a 'foo' row without a corresponding 'foo_bar',
then I get AttributeError. It is clearly looking for a 'bar' in a
'foo_bar' that is a None (since there is no entry), so is
understandable; but in my case not desirable.

What I would like to do is to get a 'bar' if one exists, else return a
'None'. Is the only way to do this to write my own wrapper property
that does a try/catch? And if I do this, will the property stop being
nice and magical (you know, filterable and comparable etc..)

I am quite a newcomer to SQLAlchemy so go easy on me!

All the best,

Philip

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



[sqlalchemy] Re: Writing values to Postgresql type Float

2011-01-19 Thread wilbur
Thanks again,

Your first script ran fine. I ended up doing something like this:


session.add(test_floats(id=2,max_pm10=Decimal(str(76945.283959)),
mean_pm10=Decimal(str(7683.27835

It was the only thing that eventually worked...






On Jan 19, 10:37 am, Michael Bayer mike...@zzzcomputing.com wrote:
 I am assuming you ran the script that I sent previously, and it produced the 
 same errors.    If this is not the case, please run that script.  If it runs 
 without errors, then the solution is to ensure your program is passing 
 numerical values in the identical fashion as the test script, and that your 
 table was created in postgresql using DOUBLE PRECISION as the data type.

 Assuming you ran the script I gave you and it produces the same errors, here 
 is a psycopg2 script.  Run it on your environment - if it fails, please 
 report the issue to the psycopg2 list, including psycopg2 and postgresql 
 version information, at:  
 http://mail.postgresql.org/mj/mj_wwwusr/domain=postgresql.org?func=li...

 import psycopg2

 conn = psycopg2.connect(user='scott', password='tiger', host='localhost', 
 database='test')

 cursor = conn.cursor()
 cursor.execute(
 CREATE TABLE double_prec_test (
     double_value DOUBLE PRECISION
 )
 )

 cursor.execute(INSERT INTO double_prec_test VALUES (%(value)s), 
 {'value':7684.4933})

 cursor.execute(SELECT * FROM double_prec_test)

 print cursor.fetchall()

 cursor.close()
 conn.close()

 On Jan 19, 2011, at 12:11 PM, wilbur wrote:

  Thanks for responding,

  I am using Postgresql 8.3.8 and Postgis 1.4. I have tried using both
  DOUBLE_PRECISION and DOUBLE_PRECISION(asdecimal=True), with the same
  errors.

  thanks

  On Jan 18, 3:50 pm, Michael Bayer mike...@zzzcomputing.com wrote:
  Here's a tested example of DOUBLE_PRECISION using both float and Decimal 
  versions.  Make sure you're on a recent release of psycopg2:

  from sqlalchemy import Column, create_engine, Integer
  from sqlalchemy.orm import Session
  from sqlalchemy.ext.declarative import declarative_base
  from sqlalchemy.dialects.postgresql import DOUBLE_PRECISION
  from decimal import Decimal

  Base = declarative_base()

  class dream4_eta_15km_pm10(Base):
     __tablename__='pm10_dream_rasters'

     id = Column(Integer, primary_key=True)

     # use float values
     max_pm10=Column(DOUBLE_PRECISION)

     # use Decimal values
     mean_pm10=Column(DOUBLE_PRECISION(asdecimal=True))

     def __repr__(self):
         return dream4_eta_15km_pm10(%r, %r) % (self.max_pm10, 
  self.mean_pm10)

  engine = create_engine('postgresql://scott:tiger@localhost/test', 
  echo=True)

  Base.metadata.create_all(engine)

  sess = Session(engine)

  sess.add(dream4_eta_15km_pm10(max_pm10=76945.283959, 
  mean_pm10=Decimal(7683.27835)))

  sess.commit()

  print sess.query(dream4_eta_15km_pm10).all()

  On Jan 18, 2011, at 3:24 PM, wilbur wrote:

  Hello,

  I am having problems using sqlalchemy to write values to Postgresq
  columns of type Float. I am getting sqlalchemy.exc.ProgrammingError:
  (ProgrammingError) can't adapt errors when I try to insert records.

  My Postgresql table is defined as:

      Column     |              Type
  |                            Modifiers
  +
  +--
  max_pm25       | double precision               |
  mean_pm25      | double precision               |

  After importing the Postgresql dialect:

  from sqlalchemy.dialects.postgresql import *

  I define my sqlalchemy table as:

  class dream4_eta_15km_pm10(Base):
     __tablename__='pm10_dream_rasters'
     max_pm10=Column(DOUBLE_PRECISION)
     mean_pm10=Column(DOUBLE_PRECISION)

  Any help appreciated,

  Bill

  --
  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 
  sqlalchemy+unsubscr...@googlegroups.com.
  For more options, visit this group 
  athttp://groups.google.com/group/sqlalchemy?hl=en.

  --
  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 
  sqlalchemy+unsubscr...@googlegroups.com.
  For more options, visit this group 
  athttp://groups.google.com/group/sqlalchemy?hl=en.

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] scalar association_proxy

2011-01-19 Thread A.M.

On Jan 19, 2011, at 12:52 PM, AgentOrange wrote:

 Hi Folks,
 
 I have been scratching my head over this one all day, so any advice
 would be greatly appreciated!
 
 I have a pretty simple join table setup like this:
 
 foo foo_bar  bar
 ---
 id  id_foo (unique)  id
id_bar
more_stuff
 
 It looks like a many-to-many relationship, but it's not, since id_foo
 is unique in the join table.
 
 - There can be any number of 'foo' for each 'bar'
 - Each 'foo' has exactly one or zero 'bar'
 
 I have set up the required declarative stuff, and an association proxy
 in 'foo' to get to 'bar' in one nice step. Since there can only ever
 be one (or zero - and this is my problem) I have set it to be a
 scalar.
 
 It all works great, except that if I try and look at the value of the
 assoication proxy in a 'foo' row without a corresponding 'foo_bar',
 then I get AttributeError. It is clearly looking for a 'bar' in a
 'foo_bar' that is a None (since there is no entry), so is
 understandable; but in my case not desirable.
 
 What I would like to do is to get a 'bar' if one exists, else return a
 'None'. Is the only way to do this to write my own wrapper property
 that does a try/catch? And if I do this, will the property stop being
 nice and magical (you know, filterable and comparable etc..)
 
 I am quite a newcomer to SQLAlchemy so go easy on me!

Did you use uselist=False on foo.bar and the associationproxy? It would nice if 
you could show some code.
http://www.sqlalchemy.org/docs/orm/extensions/associationproxy.html?highlight=uselist

Cheers,
M

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



[sqlalchemy] ResultProxy bug?

2011-01-19 Thread David Gardner

Ran into an issue with having periods in column headings of SQL queries.
--
import sqlalchemy as sa

print(sa.__version__)
DB_URI = postgresql+psycopg2://test:test@localhost/testdb
engine = sa.create_engine (DB_URI)


qry = SELECT 1 AS test.this;
results = engine.execute(qry)
print(results.keys()==['this'])


--
David Gardner
Pipeline Tools Programmer
Jim Henson Creature Shop
dgard...@creatureshop.com


--
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



[sqlalchemy] Re: scalar association_proxy

2011-01-19 Thread AgentOrange
Hi ho,

Thanks for the swift reply!

 Did you use uselist=False on foo.bar and the associationproxy? It would nice 
 if you could show some 
 code.http://www.sqlalchemy.org/docs/orm/extensions/associationproxy.html?h...

Yes I did. The code is more complicated as it has a bunch of other
stuff in it, but here's a condensation:

class Foo(Base):
id = Column(Integer, primary_key = True)
foo_bar_join = relationship(FooBar, primaryjoin = (id ==
FooBar.id_foo), uselist = False)
bar = association_proxy('foo_bar_join', 'bar', creator = lambda x:
FooBar(bar = x) )

class Bar(Base):
id = Column(Integer, primary_key = True)

class FooBar(Base):
id_foo = Column(Integer, ForeignKey('foo.id'), primary_key = True)
id_bar = Column(Integer, ForeignKey('bar.id'), primary_key = True)

bar = relationship(Bar, primaryjoin = (id_bar == Bar.id))
other_stuff = Column(Integer)

The problem comes if you try to fetch 'bar' from an instance of 'Foo'
for which there is no entry in the foo_bar join table.

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] ResultProxy bug?

2011-01-19 Thread David Gardner

Sorry should have mentioned that I get this with 0.6.6 and 0.6.3

On 01/19/2011 10:27 AM, David Gardner wrote:

Ran into an issue with having periods in column headings of SQL queries.
--
import sqlalchemy as sa

print(sa.__version__)
DB_URI = postgresql+psycopg2://test:test@localhost/testdb
engine = sa.create_engine (DB_URI)


qry = SELECT 1 AS test.this;
results = engine.execute(qry)
print(results.keys()==['this'])


   



--
David Gardner
Pipeline Tools Programmer
Jim Henson Creature Shop
dgard...@creatureshop.com


--
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] ResultProxy bug?

2011-01-19 Thread Michael Bayer
I think you'll find 0.7 doesn't do this anymore. SQLite has a behavior such 
that column names get converted to tablename.colname in the case of selecting 
from a UNION without explicit labels so we've always had a fixer for that.   In 
0.7 this fixer has been removed, and the sqlite dialect specifically has a less 
intrusive fixer that adjusts for this particular quirk.  


On Jan 19, 2011, at 1:27 PM, David Gardner wrote:

 import sqlalchemy as sa
 
 print(sa.__version__)
 DB_URI = postgresql+psycopg2://test:test@localhost/testdb
 engine = sa.create_engine (DB_URI)
 
 
 qry = SELECT 1 AS test.this;
 results = engine.execute(qry)
 print(results.keys()==['this'])

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] ResultProxy bug?

2011-01-19 Thread David Gardner
Would you entertain the idea of a patch to disable this behavior when 
SQLite isn't being used?


How soon do you want users to start testing of 0.7?

On 01/19/2011 11:05 AM, Michael Bayer wrote:
I think you'll find 0.7 doesn't do this anymore. SQLite has a 
behavior such that column names get converted to tablename.colname 
in the case of selecting from a UNION without explicit labels so we've 
always had a fixer for that.   In 0.7 this fixer has been removed, and 
the sqlite dialect specifically has a less intrusive fixer that 
adjusts for this particular quirk.



On Jan 19, 2011, at 1:27 PM, David Gardner wrote:


import sqlalchemy as sa

print(sa.__version__)
DB_URI = postgresql+psycopg2://test:test@localhost/testdb
engine = sa.create_engine (DB_URI)


qry = SELECT 1 AS test.this;
results = engine.execute(qry)
print(results.keys()==['this'])


--
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



--
David Gardner
Pipeline Tools Programmer
Jim Henson Creature Shop
dgard...@creatureshop.com

--
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] ResultProxy bug?

2011-01-19 Thread Michael Bayer

On Jan 19, 2011, at 3:30 PM, David Gardner wrote:

 Would you entertain the idea of a patch to disable this behavior when SQLite 
 isn't being used?

erm I'd rather not add a random flag into 0.6 which is well into maintenance 
mode...


 
 How soon do you want users to start testing of 0.7?

I just need to fill in the major parts of 
http://www.sqlalchemy.org/trac/wiki/07Migration and I can start putting out 
betas.   the code is all there.



 
 On 01/19/2011 11:05 AM, Michael Bayer wrote:
 
 I think you'll find 0.7 doesn't do this anymore. SQLite has a behavior 
 such that column names get converted to tablename.colname in the case of 
 selecting from a UNION without explicit labels so we've always had a fixer 
 for that.   In 0.7 this fixer has been removed, and the sqlite dialect 
 specifically has a less intrusive fixer that adjusts for this particular 
 quirk.  
 
 
 On Jan 19, 2011, at 1:27 PM, David Gardner wrote:
 
 import sqlalchemy as sa
 
 print(sa.__version__)
 DB_URI = postgresql+psycopg2://test:test@localhost/testdb
 engine = sa.create_engine (DB_URI)
 
 
 qry = SELECT 1 AS test.this;
 results = engine.execute(qry)
 print(results.keys()==['this'])
 
 -- 
 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 
 sqlalchemy+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/sqlalchemy?hl=en.
 
 
 -- 
 David Gardner
 Pipeline Tools Programmer
 Jim Henson Creature Shop
 dgard...@creatureshop.com
 
 -- 
 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 
 sqlalchemy+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/sqlalchemy?hl=en.

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



Re: [sqlalchemy] Re: scalar association_proxy

2011-01-19 Thread A.M.

On Jan 19, 2011, at 1:29 PM, AgentOrange wrote:

 Hi ho,
 
 Thanks for the swift reply!
 
 Did you use uselist=False on foo.bar and the associationproxy? It would nice 
 if you could show some 
 code.http://www.sqlalchemy.org/docs/orm/extensions/associationproxy.html?h...
 
 Yes I did. The code is more complicated as it has a bunch of other
 stuff in it, but here's a condensation:
 
 class Foo(Base):
id = Column(Integer, primary_key = True)
foo_bar_join = relationship(FooBar, primaryjoin = (id ==
 FooBar.id_foo), uselist = False)
bar = association_proxy('foo_bar_join', 'bar', creator = lambda x:
 FooBar(bar = x) )
 
 class Bar(Base):
id = Column(Integer, primary_key = True)
 
 class FooBar(Base):
id_foo = Column(Integer, ForeignKey('foo.id'), primary_key = True)
id_bar = Column(Integer, ForeignKey('bar.id'), primary_key = True)
 
bar = relationship(Bar, primaryjoin = (id_bar == Bar.id))
other_stuff = Column(Integer)
 
 The problem comes if you try to fetch 'bar' from an instance of 'Foo'
 for which there is no entry in the foo_bar join table.

Maybe you can squelch the exception by using a synonym with the descriptor 
argument to map to a fake property.

Cheers,
M

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.



[sqlalchemy] Re: rollback not working

2011-01-19 Thread bool

If I dont use autocommit:True option, it seems the driver will be in a
chained transaction mode and results in every single statement
(including selects) being run in a new transaction. This is not
desirable either.

Is there a way out ?

-- 
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 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.