Re: [sqlalchemy] ColanderAlchemy 0.2a1 released!

2013-04-11 Thread Werner

On 12/04/2013 00:01, Stefano Fontanelli wrote:

Hi all,
ColanderAlchemy 0.2a1 has been released on PyPi.

We are waiting feedbacks to add/remove/change features before reach 
beta version.


You can find changelog here: 
https://github.com/stefanofontanelli/ColanderAlchemy/blob/master/CHANGELOG.txt


You can find new doc here:
https://colanderalchemy.readthedocs.org/en/latest/

BTW, the "colander" link on the following page does not work.

Werner

--
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




[sqlalchemy] ColanderAlchemy 0.2a1 released!

2013-04-11 Thread Stefano Fontanelli
Hi all,
ColanderAlchemy 0.2a1 has been released on PyPi.

We are waiting feedbacks to add/remove/change features before reach beta
version.

You can find changelog here:
https://github.com/stefanofontanelli/ColanderAlchemy/blob/master/CHANGELOG.txt

You can find new doc here:
https://colanderalchemy.readthedocs.org/en/latest/

Kudos to David Beitey ( https://github.com/davidjb ) that did a great job!
Thank you very much.

Feedbacks are really appreciated.

Stefano.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [sqlalchemy] Latest sphinx with autodoc may fail with SQLAlchemy models

2013-04-11 Thread Michael Bayer
I had a tentative fix for that .key issue but I hadn't committed it since 
repr() usually isn't called, but I'll commit that in today.


On Apr 11, 2013, at 3:56 PM, Jason  wrote:

> Just a heads up that it looks like Sphinx 1.2b1 (the latest release on PyPi) 
> may not work when using the autodoc plugin on SQLAlchemy models. I've created 
> a ticket at 
> https://bitbucket.org/birkenfeld/sphinx/issue/1143/breaks-on-some-attributes 
> for Sphinx, but it also seems weird that the RelationshipProperty can't 
> handle having repr() being called on it.
> 
> --
> Jason
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sqlalchemy+unsubscr...@googlegroups.com.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




[sqlalchemy] Latest sphinx with autodoc may fail with SQLAlchemy models

2013-04-11 Thread Jason
Just a heads up that it looks like Sphinx 1.2b1 (the latest release on 
PyPi) may not work when using the autodoc plugin on SQLAlchemy models. I've 
created a ticket 
at https://bitbucket.org/birkenfeld/sphinx/issue/1143/breaks-on-some-attributes 
for Sphinx, but it also seems weird that the RelationshipProperty can't 
handle having repr() being called on it.

--
Jason

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [sqlalchemy] No Error get raised when changing an immutable pickle type ?

2013-04-11 Thread Michael Bayer
the "mutable" flag has been removed, for one thing.  For another, when you 
change the value of the thing you're pickling, that's a plain Python object, 
like a list or a dictionary.  It has no way of emitting an event on change 
unless you've designed it to do so.


On Apr 11, 2013, at 12:28 PM, rohit  wrote:

> I think SQL Alchemy should raise some exception when a code tries to change 
> the value of a Pickle type attribute when mutable = False.
> Reason for this is that user has accepted an attribute to be immutable and 
> still trying to change the value.
> Can anyone explain the reason for not having so ?
> 
> http://docs.sqlalchemy.org/en/rel_0_8/core/types.html#sqlalchemy.types.PickleType
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sqlalchemy+unsubscr...@googlegroups.com.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




[sqlalchemy] No Error get raised when changing an immutable pickle type ?

2013-04-11 Thread rohit
I think SQL Alchemy should raise some exception when a code tries to change 
the value of a Pickle type attribute when mutable = False.
Reason for this is that user has accepted an attribute to be immutable and 
still trying to change the value.
Can anyone explain the reason for not having so ?

http://docs.sqlalchemy.org/en/rel_0_8/core/types.html#sqlalchemy.types.PickleType

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [sqlalchemy] polymorphic and reflection

2013-04-11 Thread Michael Bayer

On Apr 11, 2013, at 6:49 AM, Treeve Jelbert  wrote:

> I am using reflection on an existing database
> 
> ##
> engine = create_engine(login.connection)
> 
> metadata = MetaData(bind=engine)
> Base = declarative_base(metadata=metadata)
> Base.metadata.bind = engine
> #Base.metadata.reflect()
> Base.metadata.reflect(views=True)
> 
> 
> try:
>   Base.metadata.create_all()
> except Exception, e:
>   print 'unable to access database, check the username/password\n',e
>   sys.exit()
> 
> 
> 
> 
> If I  activate __tablename__ and  __table_args__ for Invoice and Expense, 
> sqlalchemy generates SQL which references non-existant tables.
> 
> If I manually add views for  Invoice and Expense everything works.

working backwards, this means you're starting with a DB that does not have 
"invoice" or "expense", and I guess you want them to be views.   There's not 
much built-in for CREATE VIEW (which also requires a SELECT construct, since 
that's what a view comes from), we do have a recipe you can use that's here: 
http://www.sqlalchemy.org/trac/wiki/UsageRecipes/Views

however it might be easier just to do literal DDL for those views, ie. you 
write out the "CREATE VIEW" as you are, but to add it to your process you can 
use the DDL() construct:

from sqlalchemy import DDL, event

event.listen(metadata, "after_create", DDL("CREATE VIEW invoice ..."))
event.listen(metadata, "after_create", DDL("CREATE VIEW expense ..."))

that doesn't yet solve the problem of Invoice/Expense having Table metadata 
that's creating, a quick way to omit them is just to give them their own 
metadata, using a base class:

class ViewMetaData(Base):
__abstract__ = True
metadata = MetaData()  # replaces Base.metadata for subclasses

class Invoice(ViewMetaData):
__tablename__ = 'invoice'

   # ...


haven't run these examples here, hopefully I got them right.




> 
> 
> I am using latest rel_0_8 branch
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sqlalchemy+unsubscr...@googlegroups.com.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
> 
> 

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




[sqlalchemy] polymorphic and reflection

2013-04-11 Thread Treeve Jelbert
I am using reflection on an existing database

When I try to use polymorphic on a single table, i get an error;

./test 
Traceback (most recent call last):
  File "Knowhow.py", line 35, in 
from Schema import *
  File "/home/treeve/qta/Schema.py", line 72, in 
class Invoice(Base):
  File "/usr/lib/python2.7/site-packages/sqlalchemy/ext/declarative/api.py", 
line 50, in __init__
_as_declarative(cls, classname, cls.__dict__)
  File "/usr/lib/python2.7/site-packages/sqlalchemy/ext/declarative/base.py", 
line 249, in _as_declarative
"table-mapped class." % cls
sqlalchemy.exc.InvalidRequestError: Class  does not 
have a __table__ or __tablename__ specified and does not inherit from an 
existing table-mapped class.


The original schema is:

##
engine = create_engine(login.connection)

metadata = MetaData(bind=engine)
Base = declarative_base(metadata=metadata)
Base.metadata.bind = engine
#Base.metadata.reflect()
Base.metadata.reflect(views=True)

class X(object):
pass
db=X()



class Doc(Base):
__tablename__ = "doc"
__table_args__ = {'extend_existing': True}
#id = Column(SMALLINT,primary_key=True)
#tdate = Column(Date)
#net   = Column(Numeric)
#vat   = Column(Numeric)
type = Column(String(1))
__mapper_args__ = {
'polymorphic_identity':'x',
'polymorphic_on':type
}
db.Doc = Doc

class Expense(Base):
#__tablename__ = "expense"
#__table_args__ = {'extend_existing': True}
id = Column(SMALLINT, ForeignKey('doc.id'),primary_key=True)
org = Column(SMALLINT, ForeignKey('org.id'))
__mapper_args__ = {
'polymorphic_identity':'E',
#'polymorphic_identity':'expense',
}
expenses = relationship("Expitem", backref="exp")
db.Expense = Expense


class Invoice(Base):
#__tablename__ = "invoice"
#__table_args__ = {'extend_existing': True}
id = Column(SMALLINT, ForeignKey('doc.id'),primary_key=True)
org = Column(SMALLINT, ForeignKey('org.id'))
__mapper_args__ = {
'polymorphic_identity':'I',
#'polymorphic_identity':'invoice',
}
items = relationship("Item", backref="invoice")
db.Invoice = Invoice

try:
   Base.metadata.create_all()
except Exception, e:
   print 'unable to access database, check the username/password\n',e
   sys.exit()




If I  activate __tablename__ and  __table_args__ for Invoice and Expense, 
sqlalchemy generates SQL which references non-existant tables.

If I manually add views for  Invoice and Expense everything works.


I am using latest rel_0_8 branch

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.