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.

"Error: near "(": syntax error" when using sqlite-utils indexes CLI

See original GitHub issue

This bug relates to https://github.com/simonw/sqlite-utils/issues/408#issuecomment-1066139147

New error when using CLI: “sqlite-utils indexes global.db --table”

(app-root) sqlite-utils indexes global.db --table
Error: near "(": syntax error
(app-root) sqlite-utils --version
sqlite-utils, version 3.25.1
(app-root) sqlite3 --version
3.36.0 2021-06-18 18:36:39
(app-root) python --version
Python 3.8.11

Dockerfile

FROM centos/python-38-centos7

USER root

RUN yum update -y
RUN yum upgrade -y


# epel
RUN yum -y install epel-release && yum clean all

# SQLite
RUN yum -y install zlib-devel geos geos-devel proj proj-devel freexl freexl-devel libxml2-devel 

WORKDIR /build/
COPY sqlite-autoconf-3360000.tar.gz ./
RUN tar -zxf sqlite-autoconf-3360000.tar.gz
WORKDIR /build/sqlite-autoconf-3360000
RUN ./configure
RUN make
RUN make install

# 
RUN /opt/app-root/bin/python3.8 -m pip install --upgrade pip
RUN pip install sqlite-utils

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
simonwcommented, Apr 13, 2022

I’m going to close this ticket since it looks like this is a bug in the way the Dockerfile builds Python, but I’m going to ship a fix for that issue I found so the LD_PRELOAD workaround above should work OK with the next release of sqlite-utils. Thanks for the detailed bug report!

0reactions
simonwcommented, Apr 13, 2022

Trying this alternative implementation of the register() method:

        def register(fn):
            name = fn.__name__
            arity = len(inspect.signature(fn).parameters)
            if not replace and (name, arity) in self._registered_functions:
                return fn
            kwargs = {}
            done = False
            if deterministic:
                # Try this, but fall back if sqlite3.NotSupportedError
                try:
                    self.conn.create_function(name, arity, fn, **dict(kwargs, deterministic=True))
                    done = True
                except sqlite3.NotSupportedError:
                    pass
            if not done:
                self.conn.create_function(name, arity, fn, **kwargs)
            self._registered_functions.add((name, arity))
            return fn

With that fix, the following worked!

LD_PRELOAD=./build/sqlite-autoconf-3360000/.libs/libsqlite3.so sqlite-utils indexes /tmp/global.db --table
table      index_name                    seqno    cid  name       desc  coll      key
---------  --------------------------  -------  -----  -------  ------  ------  -----
countries  idx_countries_country_name        0      1  country       0  BINARY      1
countries  idx_countries_country_name        1      2  name          0  BINARY      1
Read more comments on GitHub >

github_iconTop Results From Across the Web

OperationalError: near ")": syntax error in sqlite - Stack Overflow
I tried changing the format still not working. ... What are the columns? Are they all strings? ... Why are you using sqlite3...
Read more >
sqlite-utils command-line tool
In Python: db.query() CLI reference: sqlite-utils query ... If a table with the same name already exists, you will get an error. You...
Read more >
(sqlite3.operationalerror) near "(": syntax error - You.com
SQLite now thinks that the field is named integer , and has no data type defined. You probably wanted to have an INTEGER...
Read more >
sqlite-utils(1) - Debian Manpages
In Python: table.indexes CLI reference: sqlite-utils indexes ... You can choose to silently ignore this error with --ignore, or you can replace the...
Read more >
sqlite-utils 2.0: real upserts
I just released version 2.0 of my sqlite-utils library/CLI tool to ... unexpected punctuation could cause an FTS syntax error in SQLite.
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