Du har redan skapat Base i Item.py , importera det bara till main.py :
Om main.py och Item.py finns i samma mapp, sedan i main.py :
from Item import Base, Item
Och ta bort all import inom main funktion, så main.py kommer att se ut så här:
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from Item import Base, Item
def main():
engine = create_engine('postgresql+psycopg2://me:example@sqldat.com/my_first_database', echo=True)
print(Item)
print(Item.__table__)
Base.metadata.create_all(engine)
main()