title: SQLAlchemy inserts row to MYSQL database, then removed 3-5 seconds after. No traceback. Python3
body: <p>At the moment, I am using Session 'With' Managers with two scripts running in two docker containers, connected to a third mysql docker container. They are running at the same time, polling for updates.</p>
  <p>There are multiple of these in both scripts:</p>
  <pre><code>with Session(bind=engine, expire_on_commit=True) as session:
          with session.begin():
              check_for_sheet_updates(session)
  </code></pre>
  <p>I'm not doing any <code>session.commit()</code>s, only <code>session.add()</code>s.</p>
  <p>It's such weird behaviour because one row gets added fine, and that remains in the database. However, when I add another row, the second row gets removed after 4-5 seconds automatically. It shows when I run <code>SELECT * FROM sheet_instance;</code> for about 4-5 seconds then vanishes.</p>
  <p>I have tried <code>session.flush()</code> after and before adds. Nothing changes.</p>
  <p>A new session is made on the first script whenever I make a Telegram Request to the script, and closes when it's finished the process via the 'with' statement.</p>
  <p>No errors are made when <code>session.add()</code> is called on the second row.</p>
  <p>A new session is made on the second script every 3-10 seconds (which could be main cause).</p>
  <p>I have tried everything I can. It's pretty obvious i'm not sure how <code>Sessions</code> work. If someone could help me it would be appreciated.</p>
  <p>there is also a third file where I import database engine from:</p>
  <pre><code>from email.policy import default
  from sqlalchemy.orm import sessionmaker, Session, declarative_base, relationship
  from sqlalchemy import create_engine, MetaData, Table, Column, Integer, String, Boolean, inspect
  from sqlalchemy_utils import database_exists, create_database
  import os
  import time
  import datetime
  
  
  SQL_BINANCE_USERNAME = os.getenv('SQL_BINANCE_USERNAME')
  SQL_BINANCE_PASSWORD = os.getenv('SQL_BINANCE_PASSWORD')
  
  
  mysql_conn_str = f&quot;mysql+pymysql://{SQL_BINANCE_USERNAME}:{SQL_BINANCE_PASSWORD}@binance_bot_creator_net:3306&quot;
  
  engine = create_engine(mysql_conn_str)
  
  
  Base = declarative_base()
  connection = engine.connect()
  
  connection.execute(&quot;CREATE DATABASE IF NOT EXISTS instances&quot;)
  connection.execute(&quot;commit&quot;)
  
  mysql_conn_str = f&quot;{mysql_conn_str}/instances?charset=utf8mb4&quot;
  engine = create_engine(mysql_conn_str, pool_pre_ping=True, pool_size=10, max_overflow=15, pool_timeout=30)
  
  Base = declarative_base()
  connection = engine.connect()
  
  
  
  sessionMade = sessionmaker(bind=engine)
  
  
  class Sheet_Instance(Base):
      __tablename__ = &quot;sheet_instance&quot;
  
      id = Column(Integer, primary_key = True)
      api_key = Column(String(128))
      api_secret = Column(String(128))
      gid = Column(String(128))
      sheet_name = Column(String(128))
      sheet_name_lower = Column(String(128))
      symbol = Column(String(128))
      active = Column(Boolean(), default=False)
      notification_chat_id = Column(String(128), default=&quot;-1001768606486&quot;)
  
  
  Base.metadata.create_all(engine)
  </code></pre>
  <p>On the two script files, I import <code>engine</code> and <code>Sheet_Instance</code> from the file above.</p>
  <p>I'm not sure what to do.</p>