我有此代码:
def start() -> scoped_session:
engine = create_engine(os.environ.get(DB_URL))
base.metadata.create_all(engine)
return scoped_session(sessionmaker(bind=engine, autoflush=False))
base = declarative_base()
session = start()
还有另一个代码:
class limit(base):
__tablename__ = 'req_limit'
user_id = Column(Integer, primary_key=True)
limit_count = Column(Integer, default=0)
我该如何从变量中获取用户,并从另一个变量中获取限制数,将其添加到数据库中?
我想将它们添加到列中然后将它们取出,并且需要以某种方式链接它们(用户和ID),因此在此之后,我将能够使用limit_cont并根据用户名。
user = 'ABC'
limit_count = 1