You need to pass in a sequence, but you forgot the comma to make your parameters a tuple:
cursor.execute('INSERT INTO images VALUES(?)', (img,))
Without the comma, (img)
is just a grouped expression, not a tuple, and thus the img
string is treated as the input sequence. If that string is 74 characters long, then Python sees that as 74 separate bind values, each one character long.
>>> len(img) 74 >>> len((img,)) 1
If you find it easier to read, you can also use a list literal:
cursor.execute('INSERT INTO images VALUES(?)', [img])
Related Posts:
- Django – no such table exception
- Sqlite3, OperationalError: unable to open database file
- Django – no such table exception
- sqlite3.OperationalError: unable to open database file
- OperationalError: database is locked
- How do I lowercase a string in Python?
- ValueError: Unknown label type: ‘continuous’
- Transpose/Unzip Function (inverse of zip)?
- TypeError: unhashable type: ‘numpy.ndarray’
- python base64 to hex
- What’s the canonical way to check for type in Python?
- IndexError: tuple index out of range —– Python
- What is the pythonic way to calculate dot product?
- How to resize an image with OpenCV2.0 and Python2.6
- Is there a ‘foreach’ function in Python 3?
- How to condense if/else into one line in Python?
- Depth-first search (DFS) code in python
- How to use Python to execute a cURL command?
- What does %s mean in a python format string?
- Redirecting to URL in Flask
- How to use torch.stack function
- (Help) TypeError: ‘str’ object cannot be interpreted as an integer
- ‘builtin_function_or_method’ object is not iterable
- Why KeyError: 0
- bash: pip: command not found
- How do I concatenate two lists in Python?
- Convert a tensor to numpy array in Tensorflow?
- How to run Conda?
- How do I check whether a file exists without exceptions?
- How can I get dictionary key as variable directly in Python (not by searching from value)?
- pygame.error: video system not initialized
- Python – Reading and writing csv files with utf-8 encoding
- Python’s equivalent of && (logical-and) in an if-statement
- Replace values in list using Python
- Trouble updating to Anaconda Navigator 1.10.0 (MacOS)
- Binary numbers in Python
- Django: ImproperlyConfigured: The SECRET_KEY setting must not be empty
- builtins.TypeError: must be str, not bytes
- Remove all occurrences of a value from a list?
- os.path.dirname(__file__) returns empty
- keyerror 1 in my code
- ‘NoneType’ object has no attribute ‘group’
- How to fix ‘ValueError: list.remove(x): x not in list’ error in Python
- Group by index + column in pandas
- Why am I getting a FileNotFoundError?
- Anaconda Navigator won’t launch (windows 10)
- How to copy files?
- What is the difference between ‘/’ and ‘//’ when used for division?
- How do I format a string using a dictionary in python-3.x?
- How to extend a class in python?
- Converting XML to JSON using Python?
- How to import a module given the full path?
- Why does “pip install” inside Python raise a SyntaxError?
- Removing numbers from string
- importing external “.txt” file in python
- How can I remove Nan from list Python/NumPy
- Solution for SpecificationError: nested renamer is not supported while agg() along with groupby()
- Why is there no tuple comprehension in Python?
- pip: no module named _internal
- Image.open() cannot identify image file – Python?
- python socket programming OSError: [WinError 10038] an operation was attempted on something that is not a socket
- Multiple try codes in one block
- Error: Segmentation fault (core dumped)
- Error “‘type’ object has no attribute ‘__getitem__'” when iterating over list[“a”,”b”,”c”]
- Python: “TypeError: __str__ returned non-string” but still prints to output?
- ImportError: No module named ‘django.core.urlresolvers’
- Numpy, multiply array with scalar
- Python 3: Multiply a vector by a matrix without NumPy
- How to fix “Can’t find a default Python” error
- TypeError: ‘newline’ is an invalid keyword argument for this function
- datetime to string with series in pandas
- Is it possible only to declare a variable without assigning any value in Python?
- How to Install pip for python 3.7 on Ubuntu 18?
- How to add a new row to an empty numpy array
- Logical indexing with lists
- How to set timeout on python’s socket recv method?
- What is the easiest way to clear a database from the CLI with manage.py in Django?
- Printing one character at a time from a string, using the while loop
- Change the name of a key in dictionary
- Check if an object exists
- How do I calculate the date six months from the current date using the datetime Python module?
- How to embed image or picture in jupyter notebook, either from a local machine or from a web resource?
- How to make a python script wait for a pressed key?
- TypeError: Image data can not convert to float
- Mean Squared Error in Numpy?
- Turn a single number into single digits Python
- Is there a head and tail method for Numpy array?
- What should I use to open a url instead of urlopen in urllib3
- Logical operators for Boolean indexing in Pandas
- Transposing a 1D NumPy array
- Explaining Python’s ‘__enter__’ and ‘__exit__’
- numpy.float64 object is not iterable…but I’m NOT trying to
- Converting a list to a set changes element order
- Create a list with initial capacity in Python
- Accessing dict_keys element by index in Python3
- How to update Pandas from Anaconda and is it possible to use eclipse with this last
- Does python support character type?
- Styling multi-line conditions in ‘if’ statements?
- What is related_name used for?
- Symbol not found: __PyCodecInfo_GetIncrementalDecoder