On 04/14/2016 07:33 PM, Chris Withers wrote:
Hi All,

I've just released this <http://chide.readthedocs.org/en/latest/> tiny
library for making sample objects for testing.

Here's a SQLAlchemy example:

class  Parent(Base):
     __tablename__  =  'parent'
     id  =  Column(Integer,  primary_key=True)
     child_id  =  Column(Integer,  ForeignKey('child.id'))
     child  =  relationship('Child')

class  Child(Base):
     __tablename__  =  'child'
     id  =  Column(Integer,  primary_key=True)
     value  =  Column(Integer)

Now we can build a source of sample data:

from  chide.sqlalchemy  import  C o llection

samples  =  Collection({
     Parent:  {'id':  1,  'child':  Child},
     Child:  {'id':  3,  'value':  42}
})

And finally, we can use it:

session  =  Sess i on()
session.add(samples.make(Parent))
session.commit() >>> session.query(Parent).one()
<Parent ...>
_.child
<Child ...>

Hope this helps, if anyone finds bugs or has suggestions, please mail
me! cheers, Chris

neat !



--
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
<mailto:sqlalchemy+unsubscr...@googlegroups.com>.
To post to this group, send email to sqlalchemy@googlegroups.com
<mailto:sqlalchemy@googlegroups.com>.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

--
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 https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to