I need to construct a subselect, but the documentation in SQLBuilder
leaves something to be desired, so I was hoping someone with some
experience could help me out - any help will be much appreciated.
I'm writing a money management module. I have three basic classes -
transactions, transaction classes, and tabulations. the first two
describe types of monetary transactions (deposit, withdrawal, etc), and
the third adds them up based on their class (so deposits would be
positive, withdrawals would be negative). Each transaction is
associated with a particular 'budget' which serves as a container for a
set of transactions (think of it like someone's bank account)
OK, so here are my classes:
----------------------------------------------------
class Budget(SQLObject):
class sqlmeta:
table = 'org_budget'
transactions = MultipleJoin('Transaction',
joinColumn='transaction_id')
class Transaction(InheritableSQLObject):
class sqlmeta:
table = "org_transaction"
budget = ForeignKey('Budget')
amount = CurrencyCol(default=0)
transaction_class = RelatedJoin('TransactionClass',
intermediateTable="class_transaction", joinColumn="transaction_id",
otherColumn="transaction_class_id")
class TransactionClass(SQLObject):
class sqlmeta:
table = "org_transaction_class"
name = StringCol(length=200,notNone=True)
transactions = RelatedJoin('Transaction',
intermediateTable="class_transaction",
joinColumn="transaction_class_id", otherColumn="transaction_id")
class Tabulation(SQLObject):
class sqlmeta:
table = 'org_tabulation'
positive_classes =
RelatedJoin('TransactionClass',addRemoveName='PositiveClass')
negative_classes =
RelatedJoin('TransactionClass',addRemoveName='NegativeClass')
def getTransactions(self,budget):
#???
-----------------------------------------------------
I'm trying to write a query which retrieves all the transactions
defined in a tabulation's positive or negative relatedjoin for a
specific budget. the basic logic should look something like this:
SELECT transaction WHERE ( transaction.budget == budget AND
transaction.transaction_class IN tabulation.positive_classes )
Thanks again for any suggestions!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---