Ya creaste Base
en Item.py
, simplemente impórtalo en main.py
:
Si main.py
y Item.py
están en la misma carpeta, luego en main.py
:
from Item import Base, Item
Y elimina todas las importaciones dentro de main
función, entonces main.py
se verá como:
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from Item import Base, Item
def main():
engine = create_engine('postgresql+psycopg2://me:[email protected]/my_first_database', echo=True)
print(Item)
print(Item.__table__)
Base.metadata.create_all(engine)
main()