Questions tagged [pysqlite]

A DB-API2 compliant module in Python for interacting with a SQLite relational database.

139 questions
55
votes
21 answers

Python SQLite: database is locked

I'm trying this code: import sqlite connection = sqlite.connect('cache.db') cur = connection.cursor() cur.execute('''create table item (id integer primary key, itemno text unique, scancode text, descr text, price…
Soid
  • 2,051
  • 1
  • 26
  • 38
19
votes
3 answers

Why can't pip uninstall pysqlite?

I'm trying to remove pysqlite from my system using pip. What I get doing so makes no sense: $ pip uninstall pysqlite The command worked, but watch this: $ pip freeze [...] pysqlite==1.0.1 Let's try again $ pip uninstall pysqlite Can't uninstall…
shkschneider
  • 16,338
  • 12
  • 55
  • 107
16
votes
3 answers

"%s" % format vs "{0}".format() vs "?" format

In this post about SQLite, aaronasterling told me that cmd = "attach \"%s\" as toMerge" % "b.db" : is wrong cmd = 'attach "{0}" as toMerge'.format("b.db") : is correct cmd = "attach ? as toMerge"; cursor.execute(cmd, ('b.db', )) : is right…
prosseek
  • 155,475
  • 189
  • 518
  • 818
15
votes
2 answers

pysqlite: Placeholder substitution for column or table names?

Using pysqlite I am making a procedure to do something with some data. The same kind of operation is done on similar fields in multiple tables and columns, so I thought I could parameterize the sql statement as shown below: def foo(): column =…
porgarmingduod
  • 7,070
  • 7
  • 41
  • 76
15
votes
2 answers

I can't get Python's executemany for sqlite3 to work properly

I was trying to use executemany to insert values into a database, but it just won't work for me. Here is a sample: clist = [] clist.append("abc") clist.append("def") clist.append("ghi") cursor.executemany("INSERT INTO myTable(data) values (?) ",…
brainydexter
  • 17,648
  • 25
  • 70
  • 108
15
votes
5 answers

WARNING: IPython History requires SQLite, your history will not be saved

Hi I'm using Ubuntu release 12.10 (quantal) 32-bit with Linux Kernel 3.5.0-21-generic. I'm trying to get IPython's History to work. I've set it up using pythonbrew and a virtual environment. In there I use pip to install IPython. Currently, when I…
PythonJin
  • 3,289
  • 4
  • 32
  • 38
13
votes
5 answers

pysqlite2: ProgrammingError - You must not use 8-bit bytestrings

I'm currently persisting filenames in a sqlite database for my own purposes. Whenever I try to insert a file that has a special character (like é etc.), it throws the following error: pysqlite2.dbapi2.ProgrammingError: You must not use 8-bit…
Naftuli Kay
  • 75,812
  • 80
  • 244
  • 374
12
votes
3 answers

pysqlite's IntegrityError: distinguish 'NOT NULL' from 'UNIQUE' violation

In pysqlite, violating a NOT NULL or a UNIQUE constraint likewise raise an IntegrityError. Unfortunately, this Exception type does not provide an error code, but only a message. So, let's say I want to ignore unique-constraint violations, because I…
lenz
  • 4,586
  • 4
  • 22
  • 35
12
votes
3 answers

What are sqlite development headers and how to install them?

I am trying to install pysqlite and have troubles with that. I found out that the most probable reason of that is missing sqlite headers and I have to install them. However, I have no ideas what these headers are (where I can find them, what they…
Verrtex
  • 3,737
  • 9
  • 32
  • 33
10
votes
3 answers

How to use the latest sqlite3 version in python

I need to use sqlite version 3.8 or higher with python in Amazon Linux. I updated my sqlite installation to the latest version: $ sqlite3 -version 3.22.0 2018-01-22 18:45:57 0c55d179733b46d8d0ba4d88e01a25e10677046ee3da1d5b1581e86726f2171d I also…
jrauhamaa
  • 191
  • 1
  • 10
10
votes
2 answers

Symbol not found: _sqlite3_enable_load_extension - sqlite installed via homebrew

Symptom: In my Django app, when I call from pysqlite2._sqlite import * I get the traceback Symbol not found: _sqlite3_enable_load_extension when Background: I've installed python using homebrew (python 2.7.13), which auto installed sqlite I am…
Xiao Wei Chen
  • 73
  • 1
  • 8
10
votes
1 answer

ImportError: No module named pysqlite2

Why does from pysqlite2 import dbapi2 as sqlite cause ImportError: No module named pysqlite2 Isn't pysqlite2 already installed in Python 2.6.5?
jacknad
  • 12,453
  • 38
  • 115
  • 190
9
votes
2 answers

Cleaning up an internal pysqlite connection on object destruction

I have an object with an internal database connection that's active throughout its lifetime. At the end of the program's run, the connection has to be committed and closed. So far I've used an explicit close method, but this is somewhat cumbersome,…
Eli Bendersky
  • 231,995
  • 78
  • 333
  • 394
9
votes
3 answers

Install Spatialite for python (GeoDjango) on OS X

I am tearing my hair out trying to install Spatialite for GeoDjango! I am already using Homebrew, it's generally easy and convenient so I initially tried to follow the Homebrew instructions for GeoDjango. But this stops short of installing any…
Anentropic
  • 26,635
  • 9
  • 86
  • 130
8
votes
4 answers

pysqlite - how to save images

I need to save an image file into sqlite database in python. I could not find a solution. How can I do it? Thanks in advance.
Mustafa Zengin
  • 2,415
  • 3
  • 18
  • 24
1
2 3
9 10