I've worked with the Python basics for some time and fall back to mysql
for data analysis. Now I want to learn how to do OOP the Python way, but with all the reading about classes, objects and their attributes: I got lost on the way experimenting and am looking for directions.
I use Python module ciscoconfparse
, reading all interfaces, and for each interface going through spreadsheets to filter and get more (supplier) data I need.
As an example I can have the following data:
dict = {
'Customer' : 'customer1',
'supplier-con' : 'id823985',
'hostname' : 'router01',
'interface' : 'gig0/1',
'subinterface' : '101',
'dot1q' : '111',
'qinq' : '10101'
}
Tree-wise to show the relations:
the keys would look like the example below without the values:
Customer 1 : customer1
----supplier-con : id823985
-------hostname : router 1
----------interface : gi0/1
--------------subinterface : 101
--------------subinterface : 111
Customer 1 : customer1
----supplier-con : id45223
-------hostname : router 5
----------interface : gi0/3
--------------subinterface : 107
--------------subinterface : 888
Customer 2 : customer2
----supplier-con : id625544
-------hostname : router 2
----------interface : gi0/2
--------------subinterface : 202
--------------subinterface : 222
You can see the interface is used multiple times with more subinterfaces. This also counts for the hostname and could be for other details along the way.
In what kind of way should I be thinking of handling 50000 entries in memory? Or am I better of with a database?
I know how to create dict-in-dicts, but not how to make relations between each other using actual objects.