为什么在SQLAlchemy的base.metadata.create_all(引擎)在python控制台不显示表?

我正在尝试创build数据库并在其中插入值。 我正在使用postgres数据库。 我没有看到任何错误,当我跟随

>>> from sqlalchemy import create_engine >>> engine = create_engine('postgresql://postgres:password@localhost:5432/mydatabase') >>> from sqlalchemy.ext.declarative import declarative_base >>> Base = declarative_base() >>> from sqlalchemy import Column, Integer, String >>> class User(Base): ... __tablename__ = 'users' ... id = Column(Integer, primary_key=True) ... fullname = Column(String) ... password = Column(String) ... ... def __repr__(self): ... return "<User(name='%s', fullname='%s', password='%s')>" % (self.name, self.fullname, self.password) >>> User.__table__ 

给我

 Table('users', MetaData(bind=None), Column('id', Integer(), table=<users>, primary_key=True, nullable=False), Column('fullname', String(), table=<users>), Column('password', String(), table=<users>), schema=None) 

但是当我跑步

 >>> Base.metadata.create_all(engine) 

没有显示出来,在文档中给出了表和它的属性显示但没有看到运行Base.metadata.create_all(引擎)后,

有人可以提出一些解决scheme吗?

如果您想查看SQLAlchemy正在发送的命令,则需要在引擎中打开echo

 engine = create_engine('postgresql://...', echo=True) 

当然,你可以随时用psql或其他工具查看数据库。