1
votes

I'm getting the error:

sqlalchemy.exc.ArgumentError: Column type DECIMAL(38, 0) on column 'id' is not compatible with autoincrement=True

When using the official example on the Snowflake website (https://docs.snowflake.net/manuals/user-guide/sqlalchemy.html#auto-increment-behavior):

Column('id', Integer, Sequence('id_seq'), primary_key=True)

Any idea what the correct way is?

1

1 Answers

1
votes

I ran into the same issue. It works when you create a table as in the documentation and then do an insert using the same MetaData object, but it fails when you fetch the table into new metadata. I'll opened an issue for this in their repo.

A workaround is explicitly getting and putting the sequence's next value:

seq = Sequence('id_seq')
nextid = connection.execute(seq)
connection.execute(t2.insert(), [ {'id': nextid, 'data': 'test_insert'}])