[PonyORM-list] Oracle tablenames.

Bjarni Hákonarson bjarni at prentvorur.is
Tue Jul 29 04:58:53 UTC 2014


Thanks for the reply.

I am sure I violated bunch of rules in this approach but "users are stupid"
is in my opinion the first rule in software development.

Full disclosure:

What I did was this.

I used sqlacodengen and ran it towards the database schema (yes I am lazy)
.
It produces the classes automatically but with  SQLAlchemy syntax.

I then wrote a small script to translate the syntax to pony.orm'ish.

The result is as an example below.

class Customer(db.Entity):
    _table_ = 'customers'

    pk = PrimaryKey(int, auto=True)
    name = Optional(unicode)
    natid = Required(int)
    address = Optional(unicode)
    address2 = Optional(unicode)
    state = Optional(unicode)
    zip = Optional(unicode)
    city = Optional(unicode)
    phone = Optional(int)
    billing_contact = Optional(unicode)
    sysadmin = Optional(unicode)
    active = Optional(int, default=1)
    site = Set("Sites")
    person = Set("Persons")

I generally prefer to create my database schema myself using  naming
conventions like PK for Primary keys and fk_<table>
as the first columns if applicable. Create sequences and insert triggers
because so many things come free that way.

This time I finished writing the app and used cx_Oracle direct with the
associating, painstaking finger work.

I will get around to test this better soon but I wish sqlcodegen had
"--pony.orm" arg. It wold make life so much easier . :-)

Kind regards,
Bjarni
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </ponyorm-list/attachments/20140729/99179f77/attachment.html>


More information about the ponyorm-list mailing list