Skip to content
This repository has been archived by the owner on Aug 21, 2023. It is now read-only.

feat: instatiate db using sqlalch #238

Open
wants to merge 30 commits into
base: main
Choose a base branch
from

Conversation

internnos
Copy link

@internnos internnos commented Sep 10, 2022

closes #232 #227 #231

changed

  • models dir into models.py
  • Rename Starklingsuser into StarklingsUser in models.py

added

  • db.py, script to instantiate db w.r.t to models.py using sqlalch
  • verify signature in starklings-backend/starklings_backend/utils.py

github = Column(String(255), nullable=False)
username = Column(String(255), nullable=False)
score = Column(Integer, nullable=False, default=0)
starklings_user = relationship("ValidatedExercise")
Copy link
Collaborator

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

Copy link
Author

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

Copy link
Author

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'>)

@internnos internnos marked this pull request as ready for review September 16, 2022 12:22
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]:
Copy link
Collaborator

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

Copy link
Author

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()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is session defined

Copy link
Author

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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is abi defined

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flask API: Update User Information route
2 participants