title: Why does SQLAlchemy produce an insert with incorrect values
body: <p>Using the following classes and the test program at the bottom, I get a malformed Insert where the value for Application_Id is written as '(n,)', where 'n' s the value that have been inserted, i.e. if Application_Id is supposed to be 2, the value '(2,') is in it's place.</p>
  
  <p>I haven't been able to find why this happens as, as far as I can see, there's no difference in how the other foreign key columns are handled.
  (all imports excluded -- that's not the problem).</p>
  
  <p>I'm using Python 3.4.4 and SQLAlchemy 1.1.5 on Windows 10 + Visual Studio 2015. Switching to another OS or IDE is not an option :-(</p>
  
  <p>Timespan</p>
  
  <pre><code>class Timespan(Base):
      """
  
      """
      __tablename__ = 'timespan'
      def __init__(self, start, end, account, application, language):
          self.StartTime = start
          self.EndTime = end
          self.Account_Id = account
          self.Application_Id = application,
          self.Language_Id = language
  
      StartTime = Column(DateTime)
      EndTime = Column(DateTime)
      Id = Column(Integer, primary_key = True)
      Account_Id = Column(Integer, ForeignKey('account.Id'))
      Application_Id = Column(Integer, ForeignKey('application.Id'))
      Language_Id = Column(Integer, ForeignKey('language.Id'))
  </code></pre>
  
  <p>Application</p>
  
  <pre><code>class Application(Base):
      """
  
      """
      __tablename__ = 'application'
      Id = Column(Integer, primary_key = True)
      Code = Column(String)
      Description = Column(String)
  
      def __init__(self, code, description):
          self.Code = code
          self.Description = description
  </code></pre>
  
  <p>Account</p>
  
  <pre><code>class Account(Base):
      """
  
      """
  
      __tablename__ = 'account'
  
      def __init__(self, uid, domain):
          self.MvidDomain = domain
          self.MvidUid = uid
  
      Id = Column(Integer, primary_key = True)
      MvidUid = Column(Integer)
      MvidDomain = Column(String)
  </code></pre>
  
  <p>Language</p>
  
  <pre><code>class Language(Base):
      """
  
      """
      def __init__(self, description, code):
          self.Description = description
          self.Code = code
  
      __tablename__ = 'language'
  
      Id = Column(Integer, primary_key = True)
      Description = Column(String)
      Code = Column(String)
  </code></pre>
  
  <p>Test program</p>
  
  <pre><code>class TimespanTest(TestCase):
      def test_insert(self):
          engine = create_engine('sqlite://', echo = True)
          Base.metadata.create_all(engine)
  
          Session = sessionmaker(bind = engine)
          session = Session()
          application = Application(code = 'itw', description = 'desc')
          lang = Language(description = 'test language', code = 'da')
          account = Account(uid = 'test_user', domain = 'test_domain')
  
          session.add(lang)
          session.add(application)
          session.add(account)
          session.commit()
  
          print (lang.Id)
          print (application.Id)
          print (account.Id)
  
          timespan = Timespan(
                  datetime.today(), datetime.today(),
                  account = account.Id,
                  application = application.Id,
                  language = lang.Id)
          session.add(timespan)
          session.commit()
  </code></pre>
  
  <p>Debug output/Exception:</p>
  
  <pre><code>(sqlite3.InterfaceError) Error binding parameter 3 - probably unsupported type. 
  [SQL: 'INSERT INTO timespan ("StartTime", "EndTime", "Account_Id", "Application_Id", "Language_Id") VALUES (?, ?, ?, ?, ?)']
  [parameters: ('2017-01-24 08:29:23.447994', '2017-01-24 08:29:23.447994', 1, (1,), 1)]
  </code></pre>
  
  <p>The problems is in the second to last parameter, i.e. the value (1,), which should be just plain 1.</p>