title: sqlalchemy UnmappedInstanceError: Class 'builtins.NoneType' is not mapped
body: <p>I'm saving some telegram data in a database but when I try to use <code>SESSION.add(cursor)</code> I get this error: 
  <code>
  sqlalchemy.orm.exc.UnmappedInstanceError: Class 'builtins.NoneType' is not mapped
  </code></p>
  
  <p>This is my db <strong>init</strong> file:</p>
  
  <pre><code>from sqlalchemy import create_engine
  from sqlalchemy.ext.declarative import declarative_base
  from sqlalchemy.orm import scoped_session, sessionmaker
  
  from tg_userbot import DB_URI
  
  
  def start() -&gt; scoped_session:
     engine = create_engine(DB_URI, client_encoding="utf8")
     BASE.metadata.bind = engine
     BASE.metadata.create_all(engine)
     return scoped_session(sessionmaker(bind=engine, autoflush=False))
  
  
  BASE = declarative_base()
  SESSION = start()
  </code></pre>
  
  <p>Here is my table class:</p>
  
  <pre><code> class STATS(BASE):
     __tablename__ = "stats"
  
     totaldialogs = Column(Integer, primary_key=True)
     usercount = Column(Integer)
     channelcount = Column(Integer)
     supcount = Column(Integer)
     convertedgroups = Column(Integer)
     numchannel = Column(Integer)
     numuser = Column(Integer)
     numchat = Column(Integer)
     numsuper = Column(Integer)
  
  def __init__(
      self, totaldialogs, usercount, channelcount, supcount,
      convertedgroups, numchannel, numuser, numchat, numsuper,
  ):
  
      self.totaldialogs = totaldialogs
      self.usercount = usercount
      self.channelcount = channelcount
      self.supcount = supcount
      self.convertedgroups = convertedgroups
      self.numchannel = numchannel
      self.numuser = numuser
      self.numchat = numchat
      self.numsuper = numsuper
  </code></pre>
  
  <p>And here is me trying to add some values:</p>
  
  <pre><code>db = SESSION.query(STATS).first()
  if not db:
      STATS(0, 0, 0, 0, 0, 0, 0, 0, 0)
      SESSION.add(db)
      SESSION.commit()
  </code></pre>
  
  <p>Now, when I manually insert some values with a sql GUI tool the values are added just fine. But if the table is empty the error comes out.</p>