1

i got this error:

sqlalchemy.exc.DBAPIError: (pyodbc.Error) ('HY004', '[HY004] [Microsoft][ODBC Microsoft Access Driver]Invalid SQL data type  (67) (SQLBindParameter)')
[SQL: UPDATE table SET first=?, second=? WHERE table.id = ?]
[parameters: (('Test',), 'Test', 5)]

while running this code:

...

    test = session.query(Table).filter(Table.test == test_var).first()
    test.first = "Test",
    test.second = "Test"
    session.commit()

...

for Model:

class Table(Base):
    
    __tablename__ = 'table'
    
    id = Column(Integer, primary_key=True)
    test = Column(String)
    first = Column(String)
    second = Column(String)

The first Parameter looks like a list, how could this happen and how can i fix this? This code already runs a few times without any issues, that's why i am confused about this.

Thx in advanced for your help.

1 Answer 1

3

Did you intend to include a comma at the end of this line?

   test.first = "Test",

I believe this is causing python to interpret test.first as a tuple, which it cannot insert into the table since the table is expecting a string type.

Sign up to request clarification or add additional context in comments.

1 Comment

OMG... For real i looked and tested more then 60 minutes and did not realized this comma... No words about this facepalm

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.