Spaces:
Paused
Paused
Create models.py
Browse files
models.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from sqlalchemy import Column, Integer, String, ForeignKey
|
| 2 |
+
from sqlalchemy.orm import relationship
|
| 3 |
+
from .database import Base
|
| 4 |
+
|
| 5 |
+
class User(Base):
|
| 6 |
+
__tablename__ = "users"
|
| 7 |
+
|
| 8 |
+
id = Column(Integer, primary_key=True, index=True)
|
| 9 |
+
username = Column(String, unique=True, index=True)
|
| 10 |
+
password = Column(String)
|
| 11 |
+
|
| 12 |
+
class APIKey(Base):
|
| 13 |
+
__tablename__ = "api_keys"
|
| 14 |
+
|
| 15 |
+
id = Column(Integer, primary_key=True, index=True)
|
| 16 |
+
user_id = Column(Integer, ForeignKey("users.id"))
|
| 17 |
+
key = Column(String, unique=True, index=True)
|
| 18 |
+
|
| 19 |
+
user = relationship("User")
|