<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body>
<div style="word-wrap:break-word">Here's one possible solution:
<div>1) make a singleton database handle, as in theDB.py:</div>
<div></div>
</div>
<div style="word-wrap:break-word">
<div></div>
<div>2) use the one handle everywhere it's needed, as in geneticsClasses.py:</div>
<div></div>
</div>
<div style="word-wrap:break-word">
<div></div>
<div>3) also use the handle in the connect() function, in geneticsDBMScommon.py:</div>
<div></div>
</div>
<div style="word-wrap:break-word">
<div></div>
<div>4) query programs then use the dbms entity classes and geneticsDBMScommon, basically like this: </div>
<div><br>
</div>
<div>
<blockquote type="cite">
<div>#!/usr/bin/env python</div>
<div><br>
</div>
<div>from pony.orm import *</div>
<div>import sys, os</div>
<div>import argparse</div>
<div><br>
</div>
<div>from geneticsDBMScommon import *</div>
<div>from geneticsClasses import *</div>
<div><br>
</div>
<div>def parseArgs( ):</div>
<div>    parser = argparse.ArgumentParser(description="""Analyze variants""" )</div>
<div>    parser.add_argument('DBMS', type=str, help="key for the DBMS, an index into the access params in DBMScreds" )</div>
<div>    args = parser.parse_args()</div>
<div>    return args</div>
<div><br>
</div>
<div>args=parseArgs()</div>
<div>Connect( args.DBMS, debug=True )</div>
</blockquote>
</div>
<div>
<div>o o o</div>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
<div>
<div>On Nov 5, 2014, at 1:46 PM, Arthur Goldberg <<a href="mailto:Arthur.Goldberg@mssm.edu">Arthur.Goldberg@mssm.edu</a>></div>
<div> wrote:</div>
<br class="x_Apple-interchange-newline">
<blockquote type="cite">
<div style="word-wrap:break-word"><br>
<div>
<div>On Nov 5, 2014, at 1:29 PM, Arthur Goldberg <<a href="mailto:Arthur.Goldberg@mssm.edu">Arthur.Goldberg@mssm.edu</a>></div>
<div> wrote:</div>
<br class="x_Apple-interchange-newline">
<blockquote type="cite">
<div>
<div style="word-wrap:break-word">Hello Alexander
<div><br>
</div>
<div> let me be more specific.</div>
<div> I have a number of modules that query, update, delete against the database.</div>
<div> I want to centralize all the database bind, mapping,  and table deletion operations in one module that other modules can call.</div>
<div> Here's my effort to write that centralized module.</div>
<div> The only method is:</div>
<div>Connect( DBMS='arthur_minerva', entityNames=[], dropAndCreateTable=False, debug=False )</div>
<div>DBMS is simply a key into a dictionary of database credential parameters. That works fine, and is used by bind.</div>
<div>entityNames is a list of entities;  I want to connect() to make sure that if an  entity is declared as a pony db  entity then it is in the database</div>
<div>dropAndCreateTable  controls whether tables are dropped; if it is true then tables for all entities should be dropped and then created</div>
<div>
<div><br>
</div>
<div> with the call:</div>
<div>
<div>Connect( MyDropAndCreateTables.args.DBMS, entityNames='CNV Subject'.split(), </div>
<div>            dropAndCreateTable=True, debug=True )</div>
</div>
<div>
<div> this does not work, however:</div>
</div>
<div><br>
</div>
</div>
</div>
</div>
</blockquote>
it generates this error:</div>
<div>
<div>b4 db.bind</div>
<div>GET NEW CONNECTION</div>
<div>RELEASE CONNECTION</div>
<div>db.bind</div>
<div>b4 db.generate_mapping</div>
<div>GET CONNECTION FROM THE LOCAL POOL</div>
<div>SET foreign_key_checks = 0</div>
<div>COMMIT</div>
<div>SET foreign_key_checks = 1</div>
<div>CLOSE CONNECTION</div>
<div>db.generate_mapping</div>
<div>entity: CNV</div>
<div>entityObj: <class 'geneticsClasses.CNV'></div>
<div>geneticsDBMScommon.pyc: WARNING: Pony MappingError: Database object is not bound with a provider yet</div>
<div>geneticsDBMScommon.pyc: WARNING: Cannot drop_table()</div>
<div><br>
</div>
<div><br>
</div>
<blockquote type="cite">
<div>
<div style="word-wrap:break-word">
<div>
<div></div>
<div></div>
</div>
</div>
<div style="word-wrap:break-word">
<div>
<div></div>
<div></div>
</div>
</div>
<div style="word-wrap:break-word">
<div>
<div></div>
<div><br>
</div>
<div>I am using mysql. </div>
<div><br>
<div>
<div>On Nov 4, 2014, at 4:39 PM, Alexander Kozlovsky <<a href="mailto:alexander.kozlovsky@gmail.com">alexander.kozlovsky@gmail.com</a>> wrote:</div>
<blockquote type="cite">
<div dir="ltr"><span style="font-family:arial,sans-serif; font-size:13px">Hi Arthur,<br>
<br>
> How can I have the general purpose programs load all the pony entities, but then use only those specified on a command line?<br>
</span><br>
What do you mean by 'use'? Why this general purpose program can't use all entities? Can you provide some example?<br>
<br>
<div class="x_x_gmail_extra"><br>
<div class="x_x_gmail_quote">On Wed, Nov 5, 2014 at 12:24 AM, Goldberg, Arthur P <span dir="ltr">
<<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__mailto-3Aarthur.p.goldberg-40mssm.edu&d=AAMFaQ&c=4R1YgkJNMyVWjMjneTwN5tJRn8m8VqTSNCjYLg1wNX4&r=TntoeYH7lekXzpBRjXwLTkqiWTbWAvp3pHKo_kZp5qI&m=-l9d_YgpS5Br4HVerevDUPDePIdahRQvh6kua6GEKCg&s=8BLVACjagdDyNx90SlAn1F7tsSllEw4K5MHFxb6KM1o&e=" target="_blank">arthur.p.goldberg@mssm.edu</a>></span>
 wrote:<br>
<blockquote class="x_x_gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
Hi Guys<br>
<br>
I've pony entities (class foo(db.Entity), etc.) definitions in multiple modules. And I've several general purpose programs: 1) connect to the dbms and optionally create tables, 2) load a file into a table, etc.<br>
How can I have the general purpose programs load all the pony entities, but then use only those specified on a command line?<br>
<br>
Is this clear?<br>
<br>
thanks<br>
Arthur<br>
<br>
_______________________________________________<br>
ponyorm-list mailing list<br>
<a href="mailto:ponyorm-list@ponyorm.org">ponyorm-list@ponyorm.org</a><br>
<a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__mailman-2Dmail5.webfaction.com_listinfo_ponyorm-2Dlist&d=AAMFaQ&c=4R1YgkJNMyVWjMjneTwN5tJRn8m8VqTSNCjYLg1wNX4&r=TntoeYH7lekXzpBRjXwLTkqiWTbWAvp3pHKo_kZp5qI&m=-l9d_YgpS5Br4HVerevDUPDePIdahRQvh6kua6GEKCg&s=ZTWdoePYiHrdwy3YThpUs2-mmvop7hGq2ibwteX9CYA&e=" target="_blank">/ponyorm-list</a><br>
</blockquote>
</div>
<br>
</div>
</div>
_______________________________________________<br>
ponyorm-list mailing list<br>
<a href="mailto:ponyorm-list@ponyorm.org">ponyorm-list@ponyorm.org</a><br>
<a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__mailman-2Dmail5.webfaction.com_listinfo_ponyorm-2Dlist&d=AAIGaQ&c=4R1YgkJNMyVWjMjneTwN5tJRn8m8VqTSNCjYLg1wNX4&r=TntoeYH7lekXzpBRjXwLTkqiWTbWAvp3pHKo_kZp5qI&m=-l9d_YgpS5Br4HVerevDUPDePIdahRQvh6kua6GEKCg&s=ZTWdoePYiHrdwy3YThpUs2-mmvop7hGq2ibwteX9CYA&e=">https://urldefense.proofpoint.com/v2/url?u=https-3A__mailman-2Dmail5.webfaction.com_listinfo_ponyorm-2Dlist&d=AAIGaQ&c=4R1YgkJNMyVWjMjneTwN5tJRn8m8VqTSNCjYLg1wNX4&r=TntoeYH7lekXzpBRjXwLTkqiWTbWAvp3pHKo_kZp5qI&m=-l9d_YgpS5Br4HVerevDUPDePIdahRQvh6kua6GEKCg&s=ZTWdoePYiHrdwy3YThpUs2-mmvop7hGq2ibwteX9CYA&e=</a>
<br>
</blockquote>
</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; orphans:2; text-indent:0px; text-transform:none; white-space:normal; widows:2; 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; orphans:2; text-indent:0px; text-transform:none; white-space:normal; widows:2; 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; orphans:2; text-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px; word-wrap:break-word">
<span class="x_x_Apple-style-span" style="border-collapse:separate; border-spacing:0px">
<div style="word-wrap:break-word"><span class="x_x_Apple-style-span" style="border-collapse:separate; font-family:Helvetica; font-style:normal; font-variant:normal; font-weight:normal; letter-spacing:normal; line-height:normal; orphans:2; text-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px; border-spacing:0px; font-size:medium">
<div style="word-wrap:break-word"><span class="x_x_Apple-style-span" style="orphans:2; text-indent:0px; widows:2">
<div style="word-wrap:break-word"><span class="x_x_Apple-style-span" style="orphans:2; text-indent:0px; widows:2">
<div style="word-wrap:break-word"><span class="x_x_Apple-style-span" style="orphans:2; text-indent:0px; widows:2">
<div style="word-wrap:break-word"><span class="x_x_Apple-style-span" style="orphans:2; text-indent:0px; widows:2">
<div style="word-wrap:break-word"><span class="x_x_Apple-style-span" style="orphans:2; text-indent:0px; widows:2">
<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">
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; 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 class="x_x_Apple-interchange-newline">
<br class="x_x_Apple-interchange-newline">
</div>
<br>
</div>
</div>
</div>
</div>
<span><geneticsDBMScommon.py></span><span><geneticsSubjects.py></span></blockquote>
</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; orphans:2; text-indent:0px; text-transform:none; white-space:normal; widows:2; 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; orphans:2; text-indent:0px; text-transform:none; white-space:normal; widows:2; 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; orphans:2; text-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px; word-wrap:break-word">
<span class="x_Apple-style-span" style="border-collapse:separate; border-spacing:0px">
<div style="word-wrap:break-word"><span class="x_Apple-style-span" style="border-collapse:separate; font-family:Helvetica; font-style:normal; font-variant:normal; font-weight:normal; letter-spacing:normal; line-height:normal; orphans:2; text-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px; border-spacing:0px; font-size:medium">
<div style="word-wrap:break-word"><span class="x_Apple-style-span" style="orphans:2; text-indent:0px; widows:2">
<div style="word-wrap:break-word"><span class="x_Apple-style-span" style="orphans:2; text-indent:0px; widows:2">
<div style="word-wrap:break-word"><span class="x_Apple-style-span" style="orphans:2; text-indent:0px; widows:2">
<div style="word-wrap:break-word"><span class="x_Apple-style-span" style="orphans:2; text-indent:0px; widows:2">
<div style="word-wrap:break-word"><span class="x_Apple-style-span" style="orphans:2; text-indent:0px; widows:2">
<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">
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; 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 class="x_Apple-interchange-newline">
<br class="x_Apple-interchange-newline">
</div>
<br>
</div>
</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-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px; word-wrap:break-word">
<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-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px; word-wrap:break-word">
<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-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px; word-wrap:break-word">
<span class="x_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-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px; border-spacing:0px; font-size:medium">
<div style="word-wrap:break-word"><span class="x_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-indent:0px; text-transform:none; white-space:normal; widows:2; word-spacing:0px; border-spacing:0px; font-size:medium">
<div style="word-wrap:break-word"><span class="x_Apple-style-span" style="orphans:2; text-indent:0px; widows:2">
<div style="word-wrap:break-word"><span class="x_Apple-style-span" style="orphans:2; text-indent:0px; widows:2">
<div style="word-wrap:break-word"><span class="x_Apple-style-span" style="orphans:2; text-indent:0px; widows:2">
<div style="word-wrap:break-word"><span class="x_Apple-style-span" style="orphans:2; text-indent:0px; widows:2">
<div style="word-wrap:break-word"><span class="x_Apple-style-span" style="orphans:2; text-indent:0px; widows:2">
<div style="word-wrap:break-word">
<div style="word-wrap:break-word">
<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; 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; 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; 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; 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; 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; 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="x_Apple-interchange-newline">
<br class="x_Apple-interchange-newline">
</div>
<br>
</div>
</div>
</body>
</html>