[PonyORM-list] Creating Dynamic Classes in Pony (need help)

Ivan Evstegneev webmailgroups at gmail.com
Sun Mar 15 22:51:43 UTC 2015


Greetings Alex,

>>>>What database do you plan to use? Is it SQLite, PostgreSQL or something else?

As long as it works under Python’s hood I don’t actually care about which one of above DB to use )))) (no offense here, just kidding)
I’ve googled a lot and have read some papers about DBs in general, so for now I can sort them for two types: SQL based (Relational Dbs?) and ORM DBs (which enables me to write code without using SQL syntax). 

I mentioned before, that I’m new to all that DB stuff, so the easier it will be (at least at the beginning) the better. 
That is likely, one of the main reasons, why I chose Pony ORM, because of its simplicity.

Still your advice here will be appreciated.

>>>>When you loading your info from "xls" files, what do you expect to do with these data? Is it intended to be stored in the database for a long time, 
>>>>or do you just want to temporary load information to the database, process it and then store result somewhere else?


A couple of words about my project.

This project is about SDON (Software Defined Optical Networking) kind of a fork from SDN(Software Defined Networking).
The main goal of it, is to create (or actually virtualize) and describe L1 elements(physical equipment), and enhance their "virtual" capabilities in order to manage them from upper layers. 

For this purpose  I’ve defined elements as Nodes and Links (edges), using the Graph Theory analogy. 

Each one of nodes is represented by “xls” file which includes all the physical info about that element.

Particularly in the manner I've described earlier. Refer to the example of values and parameters table. 

The same is about the links. 

In general, I intend to use those “xls” files for system initialization only. 
Meaning, that I would gather all the data from those files and put them into Data Base image, which in turn I will be using while manipulating my system.
For manipulation/control purposes I'll build a separate python modules which will include all the control functions I need. 
These control functions should change values in DB image according to my needs. 
Furthermore, after loading my data from "xls" files I shall work only with DB image I created.

Hope the concept is somehow clear. ^_^

Finally, while "juggling" with all this stuff in my head, I found one more pitfall. I would call this: "Future Expansion" of my system. 
Just asked myself, what will happen if someone wants to define (and actually insert to "xls") some additional parameters for node or link? How my DB will be changed? Who will change (update) it? And so on... ))))

So, now I'm looking for solution which will enable me to make things dynamically (if there are any). 
 I saw a couple of possibilities to assign a dictionary to class (like **kawrgs) and then initialize a class's attributes by using key, value pairs.) The question is how I should handle such stuff in Pony? Are there any other possibilities for this "dynamic" realization?


Thanks a lot in advance.

Sincerely,


Ivan.







From: ponyorm-list [mailto:ponyorm-list-bounces at ponyorm.com] On Behalf Of Alexander Kozlovsky
Sent: Sunday, March 15, 2015 23:46
To: Pony Object-Relational Mapper mailing list
Subject: Re: [PonyORM-list] Creating Dynamic Classes in Pony (need help)

Hi Ivan!

What database do you plan to use? Is it SQLite, PostgreSQL or something else?

When you loading your info from "xls" files, what do you expect to do with these data? Is it intended to be stored in the database for a long time, or do you just want to temporary load information to the database, process it and then store result somewhere else?


On Sun, Mar 15, 2015 at 11:13 PM, Ivan Evstegneev <webmailgroups at gmail.com> wrote:
Hello,

First of all, I'm absolutely new to DBs and relatively new to Python )))).

But got my work to do (EE student  project). So please don't blame me for
incorrect terminology.

My question is simple (at least it seems so to me ^_^):

Is it possible to create a dynamic classes with pony_orm?

Something similar to this:

http://stackoverflow.com/questions/2827623/python-create-object-and-add-attr
ibutes-to-it

or this:

http://code.activestate.com/recipes/52308-the-simple-but-handy-collector-of-
a-bunch-of-named/?in=user-97991


By "dynamic" I mean that class attributes are not static.

For instance, let's say I have some "node.xls" file which contains some
table as this one:

                                param1    param2........ parmaN

element1              value 1    value2...........valueN
element2              value 1    value2...........valueN
.
.

element              value 1    value2...........valueN

So I might define a class in pony_orm  which will be called as Node() and
would include all those (param1 to paramN) and then just assign their
values.

But this is a static way. What happens when I'll ( at some time) add
param(N+1) into my "node.xls"? So in such case I would need to redefine
Node() class.
Sounds not so hard task to do... But if there some more "xls" files  and
more params will be added over time to each one of them...
I would definitely get into trouble, by spending all my free time to
actually make it up-to-date.


Hope my question clear enough.

Any provided help(ideas, code snippets of possible realization, links  etc.)
will be highly appreciated.

Thanks a lot in advance,

Ivan.


_______________________________________________
ponyorm-list mailing list
ponyorm-list at ponyorm.com
/ponyorm-list




More information about the ponyorm-list mailing list