Showing posts with label class. Show all posts
Showing posts with label class. Show all posts

Saturday, January 21, 2012

Python Note 7 (the pickle module)

In python we can use serialization functionality using pickle module. it can save live instances of objects to files and retrieve object instances from pickled files.
Code:
import pickle

class Transaction : 
 def __init__(self,userName,trnsID,payment):
  self.userName=userName
  self.trnsID=trnsID
  self.payment=payment
 
 def __del__(self):
  print("Destructed!")
 
 def getPaymentValue(self):
  return self.payment
 
 def getUserName(self) :
  return self.userName
#end of the class

Saturday, December 31, 2011

One Class Into 2 Tables

In some cases we have to create 2 tables out of one class. In such cases those tables must must maintain the referential integrity.

New Annotations Used :
  • @Table(name="Customer")  : Main table (1st table)
  • @SecondaryTable(name="CustomerDetail") : Secondary table
  • @Column(table="CustomerDetail") : Mark the fields which are going to maintain in the second table

© kani.stack.notez 2012 | Blogger Template by Enny Law - Ngetik Dot Com - Nulis