<div dir="ltr">Hi <span style="font-family:arial,sans-serif;font-size:13px">Bjarni!</span><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><font face="arial, sans-serif">In order to get table name from the entity name, Pony ORM </font><span style="font-family:arial,sans-serif">by default </span><span style="font-family:arial,sans-serif">converts entity name to upper case in Oracle, and to lower case in MySQL and PostgreSQL:</span></div>
<div><font face="arial, sans-serif"><a href="http://doc.ponyorm.com/entities.html#mapping-customization">http://doc.ponyorm.com/entities.html#mapping-customization</a><br><br>For example, if your entity called Customer, the corresponding table name will be "CUSTOMER" in Oracle and "customer" in PostgreSQL and MySQL. This way it is possible to use table name in queries without quotes.<br>
<br>It is very strange that your table names are lowercase in Oracle. It may be that your entity definitions override default entity name and specify lower-case name explicitly.<br><br>For example, if your entity is declared as:<br>
<br> class MyEntity(db.Entity):<br> a = Required(int)</font></div><div><font face="arial, sans-serif"> b = Optional(int)</font></div><div><font face="arial, sans-serif"><br>then in Oracle the default table name will be "MYENTITY". But if you define entity as:<br>
<br></font><div><font face="arial, sans-serif"> class MyEntity(db.Entity):<br> _table_ = "my_table"<br> a = Required(int)</font></div><div><font face="arial, sans-serif"> b = Optional(int)</font></div>
<div><font face="arial, sans-serif"><br></font></div><font face="arial, sans-serif">then in Oracle the corresponding table name will be "my_table". If you want to explicitly specify table name then you should specify upper-case name in Oracle:<br>
<br></font><div><font face="arial, sans-serif"> class MyEntity(db.Entity):<br> _table_ = "MY_TABLE"<br> a = Required(int)</font></div><div><font face="arial, sans-serif"> b = Optional(int)</font></div>
<div><font face="arial, sans-serif"><br></font></div><font face="arial, sans-serif">Do you use the "_table_" option in your entity definitions?<br><br>Regards,<br>Alexander<br><br></font></div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Mon, Jul 28, 2014 at 3:17 PM, Bjarni Hákonarson <span dir="ltr"><<a href="mailto:bjarni@prentvorur.is" target="_blank">bjarni@prentvorur.is</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div>Hi all,</div><div><br></div><div>and thank you authors for a great product. </div><div><br></div><div>I come from a oracle-database background and I am relatively new to python and an absolute infant in pony.orm </div>
<div><br></div><div>I am now in the midst of creating an application that uses existing Oracle database schema. I have been playing around with pony.orm and I think it would save me a ton of work if I could use that. I have already tested it towards a seperate schema and having it to create it own tables and everything works just great. However when I a ran it against a copy of the original schema it complaints it cannot find TABLE_SITE table.</div>
<div><br></div><div>The problem is that pony.orm forces tablenames to lowercase. That in itself would be fine except that also forces you to use parenthesis around tablenames in Oracle queries. </div><div><br></div><div>
(see: <a href="http://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements008.htm" target="_blank">http://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements008.htm</a>)</div>
<div><br></div><div>The results are like this: (actual names changed) </div><div><br></div><div>SQL> select * from tab;</div><div><br></div><div>TNAME<span style="white-space:pre-wrap"> </span> TABTYPE<span style="white-space:pre-wrap"> </span>CLUSTERID</div>
<div>------------------------------ ------- ----------</div><div>CUSTOMERS_SITE<span style="white-space:pre-wrap"> </span> TABLE</div><div>customers<span style="white-space:pre-wrap"> </span> TABLE</div>
<div>persons <span style="white-space:pre-wrap"> </span> TABLE</div><div>readings<span style="white-space:pre-wrap"> </span> TABLE</div><div><br></div><div>SQL> select name from customers;</div><div>
select name from customers</div><div> *</div><div>ERROR at line 1:</div><div>ORA-00942: table or view does not exist</div><div><br></div><div>Of course using "select name from "customers"; would work fine. The problem is that it would mean code-change in other applications using the same schema and that doesn't work. An older application accessing the pony.orm created schema results in:</div>
<div><br></div><div> File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/reflection.py", line 512, in reflecttable</div><div> raise exc.NoSuchTableError(<a href="http://table.name" target="_blank">table.name</a>)</div>
<div>sqlalchemy.exc.NoSuchTableError: sites</div><div><br></div><div><br></div><div>Is there any way to override the behaviour of pony.orm when creating tables for Oracle?</div><div><br></div><div>Kind regards,<br></div>
<div>
Bjarni</div></div>
<br>_______________________________________________<br>
ponyorm-list mailing list<br>
<a href="mailto:ponyorm-list@ponyorm.org">ponyorm-list@ponyorm.org</a><br>
<a href="/ponyorm-list" target="_blank">/ponyorm-list</a><br>
<br></blockquote></div><br></div>