-
Notifications
You must be signed in to change notification settings - Fork 80
feat: instatiate db using sqlalch #238
base: main
Are you sure you want to change the base?
Conversation
| github = Column(String(255), nullable=False) | ||
| username = Column(String(255), nullable=False) | ||
| score = Column(Integer, nullable=False, default=0) | ||
| starklings_user = relationship("ValidatedExercise") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename it to validated_exercises
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
according to the docs, the arg to relationship is the Class name cmiiw
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if i change to table name, i'll get this error instead
sqlalchemy.exc.ArgumentError: relationship 'starklings_user' expects a class or a mapper argument (received: <class 'sqlalchemy.sql.schema.Table'>)
| github = request.json.get('github', None) | ||
| message_hash = request.json.get('message_hash', '') | ||
| network = request.json.get('network', 'testnet') | ||
| if None in [wallet_address, signature, github]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
github is not mandatory yet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aah gotcha! on it!
|
|
||
| except IntegrityError as e: | ||
| db.session.rollback() | ||
| session.rollback() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is session defined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i have fixed it!
| db.session.commit() | ||
| return f'Welcome! {username}', 200 | ||
| # verify signature | ||
| verify_signature = VerifySignature(abi, network, wallet_address) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is abi defined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolved!
closes #232 #227 #231
changed
StarklingsuserintoStarklingsUserinmodels.pyadded
db.py, script to instantiate db w.r.t tomodels.pyusing sqlalchstarklings-backend/starklings_backend/utils.py