#!/usr/bin/python3
"""
prints the State object with the name passed
as argument from the database hbtn_0e_6_usa"""
import sys
from model_state import Base, State
from sqlalchemy import create_engine
from sqlalchemy.orm import Session

if __name__ == '__main__':
    engine = create_engine('mysql+mysqldb://{}:{}@localhost/{}'
                           .format(sys.argv[1], sys.argv[2], sys.argv[3]),
                           pool_pre_ping=True)
    Base.metadata.create_all(engine)

    session = Session(engine)
    id_i = 0
    for state in session.query(State).all():
        if sys.argv[4] == state.name:
            print("{}".format(state.id))
            break
        id_i += 1
    if id_i == len(session.query(State).all()):
        print("Not found")
    session.close()
