Python Forum
Object Oriented DB Interactions
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Object Oriented DB Interactions
#1
Currently I use xlrd xlwr with psycopg2 to move transaction records in and out of spreadsheets and postgres. That works but I am interested in learning OOP and it seemed like I could incorporate OOP in my current work. My question to the forum is whether or not that really makes sense practically?

My idea is to create a transaction class:

class transaction:
with attributes that map to the column headings for each spreadsheet. So each transaction would have a date transaction.date(), amount transaction.amount(), account transaction.account() and so forth. Further, I could create methods such as selects, inserts and updates which would retrieve, create and modify those transaction records.
Reply
#2
This post was made prematurely due to some confusion with the tab keys. I will repost.
Reply
#3
Currently I use xlrd xlwr with psycopg2 to move transaction records in and out of spreadsheets and postgres. That works but I am interested in learning OOP and it seemed like I could incorporate OOP in my current efforts My first question to the forum is whether or not that really makes sense practically?

My idea is to create a transaction class:

class transaction:
     def__init__(self,date,account,amount,theater,sales_num):
           self.date = date
           self.account = account
           self.amount = amount
           self.theater = theater
           self.sales_num = sales_num

with attributes that map to the column headings for each spreadsheet / DB table. Further, I could create methods such as selects, inserts and updates which would retrieve, create and modify those transaction records.

I can't imagine this hasn't been done with more knowledge and skill than I have so, assuming this approach makes sense, I was hoping the forum could provide some coaching on the pros and cons and possibly best strategy of this approach.

Best,

Hagen
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Lightbulb Object Oriented programming (OOP) problem OmegaRed94 6 2,917 May-31-2021, 07:19 PM
Last Post: OmegaRed94
  proteins interactions Amniote 2 2,067 May-23-2019, 07:07 AM
Last Post: Amniote
  Object Oriented Programming jackbk 8 4,458 Aug-24-2018, 01:13 PM
Last Post: Windspar
  Oriented Object ldthan 1 2,392 Mar-27-2018, 11:26 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020