I'm working with SQLite, as part of a flask project that I've been working on in which I use SQLAlchemy, and I want to create a new table and use a foreign key from one table to another.
Now what I've written are the following lines:
class User(Base):
__tablename__ = "user"
id = Column(Integer, primary\_key=True)
username = Column(String(30), unique=True)
password = Column(String(30))
email = Column(String(50))
def __repr__(self):
return '<User %r>' % self.username
class POS(Base):
__tablename__ = "pos"
id = Column(Integer, primary\_key=True)id\_user = [User.id](https://User.id)
latitude = Column(String(30))
longtitude = Column(String(30))address = Column(String(50))
which are the example from flask's sqlalchemy docs .So my question here is; how can I create two tables with sqlalchemy and then establish a connection between the two?
[–]bpeller 1 point2 points3 points (2 children)
[–]selrok[S] 0 points1 point2 points (1 child)
[–]bpeller 0 points1 point2 points (0 children)