Skip to content

Commit

Permalink
🏘️🚅 ↝ [ GP-11 ] Adding method to receive info on current inventoryITE…
Browse files Browse the repository at this point in the history
…MS table
  • Loading branch information
Gizmotronn committed Feb 13, 2024
1 parent cf0662f commit b0d0c79
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
Binary file modified .DS_Store
Binary file not shown.
55 changes: 55 additions & 0 deletions database/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
from flask import Flask, jsonify
from supabase_py import create_client

app = Flask(__name__)

# app.config["SQLALCHEMY_DATABASE_URI"] = ""
# db.init_app(app)

# Create Supabase client

SUPABASE_URL = ''
SUPABASE_KEY = ''
supabase = create_client(SUPABASE_URL, SUPABASE_KEY)

# class InventoryUsers(db.Model):
# __tablename__ = 'inventoryUSERS'

# id = db.Column(db.BigInteger, primary_key=True)
# item = db.Column(db.BigInteger, db.ForeignKey('inventoryITEMS.id'))
# owner = db.Column(db.String, db.ForeignKey('profiles.id'))
# quantity = db.Column(db.Float)
# location = db.Column(db.BigInteger, db.ForeignKey('inventoryPLANETS.id'))
# sector = db.Column(db.BigInteger, db.ForeignKey('basePlanetSectors.id'))
# planetSector = db.Column(db.BigInteger, db.ForeignKey('basePlanetSectors.id'))

# class InventoryItems(db.Model):
# __tablename__ = 'inventoryITEMS'

# id = db.Column(db.BigInteger, primary_key=True)
# name = db.Column(db.String)
# description = db.Column(db.Text)
# cost = db.Column(db.Integer)
# icon_url = db.Column(db.String)
# ItemCategory = db.Column(db.String)
# parentItem = db.Column(db.BigInteger)
# itemLevel = db.Column(db.Float, default=1.0)
# oldAssets = db.Column(db.ARRAY(db.Text))

# Route to fetch items from inventoryITEMS table
@app.route('/items')
def get_items():
# Query items from inventoryITEMS table
items = supabase.table('inventoryITEMS').select('*').execute()
return jsonify(items['data'])

# Route to fetch user inventory from inventoryUSERS table
@app.route('/inventory/<user_id>')
def get_user_inventory(user_id):
# Query user inventory from inventoryUSERS table
user_inventory = supabase.table('inventoryUSERS').select('*').eq('owner', user_id).execute()
return jsonify(user_inventory['data'])

# Main function to run the Flask app
if __name__ == '__main__':
app.run(debug=True)

0 comments on commit b0d0c79

Please sign in to comment.