0

Okay so i'm playing with sqlalchemy and got a problem. here is the code

........
def Create(cur_date, trans_status):
    new_trans = 'Transaction(date=cur_date, status=[Status(%s = 0)])' %(trans_status)

    session.add(new_trans)
    session.commit()
Create('1/12/14', 'processed')

NOTE: class Status has processed, rejected and forwarded as keys/parameters GOAL: create new transaction where Status key would be dependent on the input(trans_status) EX: if user selects status as processed, the Status(processed = 1) should be created

1 Answer 1

1

Well, new_trans will be a string instance and not a Transaction instance. How about:

new_trans = Transaction(date=cur_date, status=[Status(status = trans_status)])
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.