question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

IndexError: tuple index out of range with python3.6 and SQlAlchemy 1.4.45

See original GitHub issue

Describe the bug

Getting exception while trying below code -

        with op.batch_alter_table("<table_name>") as batch_op:

            batch_op.create_check_constraint(
                "ck_ssl_mode",
                "ssl_mode IN ('allow', 'prefer', 'require', 'disable', \
                'verify-ca', 'verify-full')"
            )

To Reproduce

with op.batch_alter_table("<table_name>") as batch_op:

            batch_op.create_check_constraint(
                "ck_ssl_mode",
                "ssl_mode IN ('allow', 'prefer', 'require', 'disable', \
                'verify-ca', 'verify-full')"
            )

Error

File "/usr/pgadmin4/web/migrations/versions/09d53fca90c7_.py", line 55, in upgrade
    'verify-ca', 'verify-full')"
  File "/usr/lib64/python3.6/contextlib.py", line 88, in __exit__
    next(self.gen)
  File "/usr/pgadmin4/venv/lib64/python3.6/site-packages/alembic/operations/base.py", line 374, in batch_alter_table
    impl.flush()
  File "/usr/pgadmin4/venv/lib64/python3.6/site-packages/alembic/operations/batch.py", line 125, in flush
    **self.reflect_kwargs
  File "<string>", line 2, in __new__
  File "/usr/pgadmin4/venv/lib64/python3.6/site-packages/sqlalchemy/util/deprecations.py", line 309, in warned
    return fn(*args, **kwargs)
  File "/usr/pgadmin4/venv/lib64/python3.6/site-packages/sqlalchemy/sql/schema.py", line 619, in __new__
    metadata._remove_table(name, schema)
  File "/usr/pgadmin4/venv/lib64/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 72, in __exit__
    with_traceback=exc_tb,
  File "/usr/pgadmin4/venv/lib64/python3.6/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
    raise exception
  File "/usr/pgadmin4/venv/lib64/python3.6/site-packages/sqlalchemy/sql/schema.py", line 614, in __new__
    table._init(name, metadata, *args, **kw)
  File "/usr/pgadmin4/venv/lib64/python3.6/site-packages/sqlalchemy/sql/schema.py", line 694, in _init
    resolve_fks=resolve_fks,
  File "/usr/pgadmin4/venv/lib64/python3.6/site-packages/sqlalchemy/sql/schema.py", line 729, in _autoload
    _extend_on=_extend_on,
  File "/usr/pgadmin4/venv/lib64/python3.6/site-packages/sqlalchemy/engine/reflection.py", line 804, in reflect_table
    reflection_options,
  File "/usr/pgadmin4/venv/lib64/python3.6/site-packages/sqlalchemy/engine/reflection.py", line 998, in _reflect_fk
    **reflection_options
  File "<string>", line 2, in __new__
  File "/usr/pgadmin4/venv/lib64/python3.6/site-packages/sqlalchemy/util/deprecations.py", line 309, in warned
    return fn(*args, **kwargs)
  File "/usr/pgadmin4/venv/lib64/python3.6/site-packages/sqlalchemy/sql/schema.py", line 619, in __new__
    metadata._remove_table(name, schema)
  File "/usr/pgadmin4/venv/lib64/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 72, in __exit__
    with_traceback=exc_tb,
  File "/usr/pgadmin4/venv/lib64/python3.6/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
    raise exception
  File "/usr/pgadmin4/venv/lib64/python3.6/site-packages/sqlalchemy/sql/schema.py", line 614, in __new__
    table._init(name, metadata, *args, **kw)
  File "/usr/pgadmin4/venv/lib64/python3.6/site-packages/sqlalchemy/sql/schema.py", line 694, in _init
    resolve_fks=resolve_fks,
  File "/usr/pgadmin4/venv/lib64/python3.6/site-packages/sqlalchemy/sql/schema.py", line 729, in _autoload
    _extend_on=_extend_on,
  File "/usr/pgadmin4/venv/lib64/python3.6/site-packages/sqlalchemy/engine/reflection.py", line 804, in reflect_table
    reflection_options,
  File "/usr/pgadmin4/venv/lib64/python3.6/site-packages/sqlalchemy/engine/reflection.py", line 998, in _reflect_fk
    **reflection_options
  File "<string>", line 2, in __new__
  File "/usr/pgadmin4/venv/lib64/python3.6/site-packages/sqlalchemy/util/deprecations.py", line 309, in warned
    return fn(*args, **kwargs)
  File "/usr/pgadmin4/venv/lib64/python3.6/site-packages/sqlalchemy/sql/schema.py", line 619, in __new__
    metadata._remove_table(name, schema)
  File "/usr/pgadmin4/venv/lib64/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 72, in __exit__
    with_traceback=exc_tb,
  File "/usr/pgadmin4/venv/lib64/python3.6/site-packages/sqlalchemy/util/compat.py", line 211, in raise_
    raise exception
  File "/usr/pgadmin4/venv/lib64/python3.6/site-packages/sqlalchemy/sql/schema.py", line 614, in __new__
    table._init(name, metadata, *args, **kw)
  File "/usr/pgadmin4/venv/lib64/python3.6/site-packages/sqlalchemy/sql/schema.py", line 694, in _init
    resolve_fks=resolve_fks,
  File "/usr/pgadmin4/venv/lib64/python3.6/site-packages/sqlalchemy/sql/schema.py", line 729, in _autoload
    _extend_on=_extend_on,
  File "/usr/pgadmin4/venv/lib64/python3.6/site-packages/sqlalchemy/engine/reflection.py", line 824, in reflect_table
    reflection_options,
  File "/usr/pgadmin4/venv/lib64/python3.6/site-packages/sqlalchemy/engine/reflection.py", line 1095, in _reflect_unique_constraints
    constraints = self.get_unique_constraints(table_name, schema)
  File "/usr/pgadmin4/venv/lib64/python3.6/site-packages/sqlalchemy/engine/reflection.py", line 632, in get_unique_constraints
    conn, table_name, schema, info_cache=self.info_cache, **kw
  File "<string>", line 2, in get_unique_constraints
  File "/usr/pgadmin4/venv/lib64/python3.6/site-packages/sqlalchemy/engine/reflection.py", line 55, in cache
    ret = fn(self, con, *args, **kw)
  File "/usr/pgadmin4/venv/lib64/python3.6/site-packages/sqlalchemy/dialects/sqlite/base.py", line 2410, in get_unique_constraints
    **kw
  File "<string>", line 2, in get_indexes
  File "/usr/pgadmin4/venv/lib64/python3.6/site-packages/sqlalchemy/engine/reflection.py", line 55, in cache
    ret = fn(self, con, *args, **kw)
  File "/usr/pgadmin4/venv/lib64/python3.6/site-packages/sqlalchemy/dialects/sqlite/base.py", line 2521, in get_indexes
    if row[4]:
IndexError: tuple index out of range

Versions

  • OS: Centos7
  • Python: 3.6.
  • SQLAlchemy: 1.4.45
  • Database: Sqlite3
  • DBAPI (eg: psycopg, cx_oracle, mysqlclient): psycopg

Additional context

No response

Issue Analytics

  • State:closed
  • Created 9 months ago
  • Reactions:1
  • Comments:18 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
yogeshmahajan-1903commented, Dec 13, 2022

ok so the issue is sqlite 3.8 added partial indexes, so previously index_list it would have 4 cols, not 5

@yogeshmahajan-1903 can you confirm that you are using sqlite3 3.32.3?

Sorry my bad. 3.32.3 is used with python 3.9. Version used with python 3.6 is 3.7.17 on cents 7

(venv) [root@localhost pgadmin]# sqlite3 ./pgadmin4.db 
SQLite version 3.7.17 2013-05-20 00:56:22
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> select sqlite_version();
3.7.17
sqlite> 
0reactions
zzzeekcommented, Dec 12, 2022

I think older sqlite’s will solve themselves in 2.0 as centos also has python 3.6 only unless you are building

Read more comments on GitHub >

github_iconTop Results From Across the Web

IndexError: tuple index out of range ----- Python - Stack Overflow
IndexError : tuple index out of range ----- Python · 8. It's saying that the index (position) you are accessing doesn't exist. ·...
Read more >
Python IndexError: tuple index out of range Solution
The IndexError: tuple index out of range error occurs when you try to access an item in a tuple that does not exist....
Read more >
IndexError: Python tuple index out of range - ArrowHiTech
The IndexError: Python tuple index out of range error occurs when you try to access an item in a tuple that does not...
Read more >
[Solved]: Python IndexError: tuple index out of range
In Python, lists, tuples are indexed. It means each value in a tuple is associated with index position (0 to n-1) to access...
Read more >
Error Messages - SQLAlchemy 1.4 Documentation
Exception raised for errors that are due to problems with the processed data like division by zero, numeric value out of range, etc....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found