<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
Alexey
<div><br>
</div>
<div>Great. Thanks
<div><br>
</div>
<div>A</div>
<div><br>
<div>
<div>On Jun 19, 2014, at 10:24 AM, Alexey Malashkevich <<a href="mailto:alexeymalashkevich@gmail.com">alexeymalashkevich@gmail.com</a>></div>
<div> wrote:</div>
<br class="Apple-interchange-newline">
<blockquote type="cite">
<div dir="ltr">Hi Arthur,
<div><br>
</div>
<div>1. The method which you've used - db.get_connection().executescript() is specific for SQLite only. </div>
<div>You need to use the method db.execute() which works for all databases: <a href="http://doc.ponyorm.com/database.html#execute" target="_blank">
http://doc.ponyorm.com/database.html#execute</a></div>
<div>Also you can use methods for dropping the database tables:</div>
<div><a href="http://doc.ponyorm.com/database.html#drop_table" target="_blank">http://doc.ponyorm.com/database.html#drop_table</a></div>
<div><a href="http://doc.ponyorm.com/database.html#drop_all_tables" target="_blank">http://doc.ponyorm.com/database.html#drop_all_tables</a></div>
<div><br>
</div>
<div>2. The official way to get all entity attributes is getting the _attrs_ attribute from the entity class:</div>
<div><br>
</div>
<div> MyEntity._attrs_</div>
<div><br>
</div>
<div>It returns the list of all the entity attributes. You can iterate over this list and examine the attribute properties. For example, this is how you can print all attribute names which are not collections (collection means one-to-many relationship attribute):</div>
<div><br>
</div>
<div> for attr in MyEntity._attrs_:</div>
<div> if not <a href="http://attr.is">attr.is</a>_collection:</div>
<div> print <a href="http://attr.name/" target="_blank">attr.name</a></div>
<div><br>
</div>
<div>Below you can see a couple of functions for getting attributes:</div>
<div>
<div><br>
</div>
<div>def get_all_attrs(entity_cls):</div>
<div> return [ attr for attr in entity_cls._attrs_ ]</div>
<div><br>
</div>
<div>def get_attrs_with_columns(entity_cls):</div>
<div> return [ attr for attr in entity_cls._attrs_with_columns_ ]</div>
<div><br>
</div>
<div>def get_collection_attrs(entity_cls):</div>
<div> return [ attr for attr in entity_cls._attrs_ if <a href="http://attr.is">
attr.is</a>_collection ]</div>
<div><br>
</div>
<div>def get_all_attr_names(entity_cls):</div>
<div> return [ <a href="http://attr.name/">attr.name</a> for attr in entity_cls._attrs_ ]</div>
</div>
<div><br>
</div>
<div>Please let us know if you have further questions.</div>
<div><br>
</div>
<div>Regards,</div>
<div>Alexey</div>
</div>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">On Thu, Jun 19, 2014 at 3:13 AM, Goldberg, Arthur P <span dir="ltr">
<<a>arthur.p.goldberg@mssm.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word">Pony's nifty -- thanks.
<div><br>
</div>
<div>Some questions:</div>
<div><br>
</div>
<div>1. Direct SQL. Suppose I want to drop a table. I thought that this would work because executescript() appears in examples</div>
<div>
<blockquote type="cite">
<div> sql = "DROP TABLE IF EXISTS %s;" % tableName</div>
<div> db.get_connection().executescript(sql)</div>
</blockquote>
</div>
<div>
<div><br>
</div>
</div>
<div>2. Entity class fields. Suppose I have</div>
<div><br>
</div>
<div>
<blockquote type="cite">
<div>class Subject(db.Entity):</div>
<div> FamilyID = Optional(str)</div>
<div> IndivID = PrimaryKey(str)</div>
<div> PatID = Optional(str, default='0')</div>
<div> MatID = Optional(str, default='0')</div>
<div> Sex = Required(str)</div>
<div> Pheno = Required(int)</div>
<div> SampleSet = Required(str)</div>
<div> variants = Set(Variant)</div>
</blockquote>
<blockquote type="cite">className = 'Subject' </blockquote>
<blockquote type="cite">self.slqobj = globals()[ className ]</blockquote>
</div>
<div>
<blockquote type="cite">
<div># I can get all fields in Subject with</div>
<div>self.slqobj._attrs_</div>
</blockquote>
</div>
<div>
<div><br>
</div>
</div>
<div>but is there an official method?</div>
<div><br>
</div>
<div>Thanks</div>
<div>Arthur</div>
<div><br>
<div>
<div style="font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; word-wrap: break-word; ">
<div style="font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; word-wrap: break-word; ">
<div style="font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; word-wrap: break-word; ">
<span style="border-collapse:separate;border-spacing:0px">
<div style="word-wrap:break-word"><span style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; border-spacing: 0px; font-size: medium; ">
<div style="word-wrap:break-word"><span style="text-align:-webkit-auto;text-indent:0px">
<div style="word-wrap:break-word"><span style="text-align:-webkit-auto;text-indent:0px">
<div style="word-wrap:break-word"><span style="text-align:-webkit-auto;text-indent:0px">
<div style="word-wrap:break-word"><span style="text-align:-webkit-auto;text-indent:0px">
<div style="word-wrap:break-word"><span style="text-align:-webkit-auto;text-indent:0px">
<div style="word-wrap:break-word">
<div style="word-wrap:break-word">
<div style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; border-spacing: 0px; font-size: medium; ">
<div style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; border-spacing: 0px; font-size: medium; ">
---</div>
<div> </div>
<div>Arthur Goldberg
<div style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; border-spacing: 0px; font-size: medium; ">
Associate Professor of Psychiatry</div>
<div>Seaver Autism Center and Icahn Institute for Genomics & Multiscale Biology</div>
<div>Icahn School of Medicine at Mount Sinai</div>
<div style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; border-spacing: 0px; font-size: medium; ">
Seaver Center, Room ABE-33</div>
<div style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; border-spacing: 0px; font-size: medium; ">
<a href="tel:212-241-4229" target="_blank">212-241-4229</a><br>
<a>Arthur.Goldberg@mssm.edu</a></div>
</div>
</div>
<div>Follow us on Twitter <a href="https://twitter.com/IcahnInstitute" target="_blank">@IcahnInstitute</a></div>
<div style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; border-spacing: 0px; font-size: medium; ">
<br>
</div>
</div>
</div>
</span></div>
</span></div>
</span></div>
</span></div>
</span></div>
</span></div>
</span></div>
</div>
</div>
<br>
<br>
</div>
<br>
</div>
</div>
<br>
_______________________________________________<br>
ponyorm-list mailing list<br>
<a>ponyorm-list@ponyorm.org</a><br>
<a href="/ponyorm-list" target="_blank">/ponyorm-list</a><br>
<br>
</blockquote>
</div>
<br>
</div>
_______________________________________________<br>
ponyorm-list mailing list<br>
<a href="mailto:ponyorm-list@ponyorm.org">ponyorm-list@ponyorm.org</a><br>
/ponyorm-list<br>
</blockquote>
</div>
<br>
<div>
<div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
<div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
<div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; border-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; ">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; border-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; ">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
<span class="Apple-style-span" style="orphans: 2; text-align: -webkit-auto; text-indent: 0px; widows: 2; -webkit-text-decorations-in-effect: none; ">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
<span class="Apple-style-span" style="orphans: 2; text-align: -webkit-auto; text-indent: 0px; widows: 2; -webkit-text-decorations-in-effect: none; ">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
<span class="Apple-style-span" style="orphans: 2; text-align: -webkit-auto; text-indent: 0px; widows: 2; -webkit-text-decorations-in-effect: none; ">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
<span class="Apple-style-span" style="orphans: 2; text-align: -webkit-auto; text-indent: 0px; widows: 2; -webkit-text-decorations-in-effect: none; ">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
<span class="Apple-style-span" style="orphans: 2; text-align: -webkit-auto; text-indent: 0px; widows: 2; -webkit-text-decorations-in-effect: none; ">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
<div style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; border-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; ">
<div style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; border-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; ">
---</div>
<div> </div>
<div>Arthur Goldberg
<div style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; border-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; ">
Associate Professor of Psychiatry</div>
<div>Seaver Autism Center and Icahn Institute for Genomics & Multiscale Biology</div>
<div>Icahn School of Medicine at Mount Sinai</div>
<div style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; border-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; ">
Seaver Center, Room ABE-33</div>
<div style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; border-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; ">
212-241-4229<br>
<a href="mailto:Arthur.Goldberg@mssm.edu">Arthur.Goldberg@mssm.edu</a></div>
</div>
</div>
<div>Follow us on Twitter <a href="https://twitter.com/IcahnInstitute">@IcahnInstitute</a></div>
<div style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; border-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; ">
<br>
</div>
</div>
</div>
</span></div>
</span></div>
</span></div>
</span></div>
</span></div>
</span></div>
</span></div>
</div>
</div>
<br class="Apple-interchange-newline">
<br class="Apple-interchange-newline">
</div>
<br>
</div>
</div>
</body>
</html>