आपने पहले ही Base बना लिया है Item.py . में , बस इसे main.py . में आयात करें :
अगर main.py और Item.py एक ही फ़ोल्डर में हैं, फिर main.py . में :
from Item import Base, Item
और main . के अंदर सभी आयात हटा दें फ़ंक्शन, इसलिए main.py ऐसा दिखेगा:
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()