pysqlite

How to install pysqlite?

半腔热情 提交于 2019-12-01 20:54:09
问题 I am trying to install pysqlite (Python interface to the SQLite). I downloaded the file with the package (pysqlite-2.5.5.tar.gz). And I did the following: gunzip pysqlite-2.5.5.tar.gz tar xvf pysqlite-2.5.5.tar \cd pysqlite-2.5.5 python setup.py install At the last step I have a problem. I get the following error message: error: command 'gcc' failed with exit status 1 I found that other peoples also had this problem. As far as I understood in the person had a problem because sqlite2 was not

Install Spatialite for python (GeoDjango) on OS X

旧时模样 提交于 2019-12-01 00:15:33
问题 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 database, i.e. Spatialite. The next step is to try and install Spatialite itself, but there are no Homebrew-specific instructions provided by Django docs. I found this tutorial which looks perfect - a Homebrew and virtualenv-friendly install of

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

时光毁灭记忆、已成空白 提交于 2019-11-30 11:43:00
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 bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings. When I do "switch my application over to Unicode strings" by wrapping the value sent to pysqlite with the unicode method like: unicode(filename) , it throws this

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

做~自己de王妃 提交于 2019-11-30 08:00:40
问题 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 (?) ", clist) This gives me the following error: sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 1, and there are 3 supplied. However, when I change the list, it works fine: clist = ["a", "b"] cursor.executemany(

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

牧云@^-^@ 提交于 2019-11-29 17:26:37
问题 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 bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings. When I do "switch my application over to Unicode strings"

ImportError: No module named pysqlite2

时光怂恿深爱的人放手 提交于 2019-11-29 13:28:18
Why does from pysqlite2 import dbapi2 as sqlite cause ImportError: No module named pysqlite2 Isn't pysqlite2 already installed in Python 2.6.5? The module is called sqlite3 . pysqlite2 was the module's name before it became part of the Python standard library. You probably want to use this in your code: import sqlite3 And the standard documentation is here: http://docs.python.org/library/sqlite3.html edit: And just to cover all the bases: The sqlite3 module also has a dbapi2 sub-member, but you don't need to use it directly. The sqlite3 module exposes all the dbapi2 members directly. 来源: https

Python SQLite: database is locked

為{幸葍}努か 提交于 2019-11-28 15:53:39
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 real)''') connection.commit() cur.close() I'm catching this exception: Traceback (most recent call last): File "cache_storage.py", line 7, in <module> scancode text, descr text, price real)''') File "/usr/lib/python2.6/dist-packages/sqlite/main.py", line 237, in execute self.con._begin() File "/usr/lib/python2.6/dist-packages/sqlite/main.py", line 503, in _begin self.db.execute("BEGIN

ImportError: No module named pysqlite2

我们两清 提交于 2019-11-28 07:22:30
问题 Why does from pysqlite2 import dbapi2 as sqlite cause ImportError: No module named pysqlite2 Isn't pysqlite2 already installed in Python 2.6.5? 回答1: The module is called sqlite3 . pysqlite2 was the module's name before it became part of the Python standard library. You probably want to use this in your code: import sqlite3 And the standard documentation is here: http://docs.python.org/library/sqlite3.html edit: And just to cover all the bases: The sqlite3 module also has a dbapi2 sub-member,

“%s” % format vs “{0}”.format() vs “?” format

耗尽温柔 提交于 2019-11-28 06:31:21
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 thing But, I've thought the first and second are the same. What are the differences between those three? "attach \"%s\" as toMerge" % "b.db" You should use ' instead of " , so you don't have to escape. You used the old formatting strings that are deprecated. 'attach "{0}" as toMerge'.format("b.db") This uses the new format string feature from newer Python

Cleaning up an internal pysqlite connection on object destruction

左心房为你撑大大i 提交于 2019-11-28 00:31:06
问题 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, especially when exceptions can happen in the calling code. I'm considering using the __del__ method for closing, but after some reading online I have concerns. Is this a valid usage pattern? Can I be sure that the internal resources will be freed