pysqlite

python http 组件简介

[亡魂溺海] 提交于 2019-12-06 14:35:46
1. mechanize https://pypi.python.org/pypi/mechanize/ 中文简介: 基于urllib2,完全兼容urllib2,提供浏览历史,表单状态,cookies等功能。 mechanize 0.2.5 Downloads ↓ Stateful programmatic web browsing. Stateful programmatic web browsing, after Andy Lester's Perl module WWW::Mechanize. mechanize.Browser implements the urllib2.OpenerDirector interface. Browser objects have state, including navigation history, HTML form state, cookies, etc. The set of features and URL schemes handled by Browser objects is configurable. The library also provides an API that is mostly compatible with urllib2: your urllib2 program will likely still

Detect the FTS3 extension in SQLite3

亡梦爱人 提交于 2019-12-05 08:54:19
What is the SQLite query to detect if the FTS3 extension module is installed? Or is it possible to get a list of installed extensions with an SQLite3 query? It has to work with pysqlite2 . I know that I can get the list of tables using SELECT * FROM sqlite_master , I'd like to get something similar for the list of extensions. I also know that CREATE VIRTUAL TABLE v USING FTS3 (t TEXT) succeeds iff FTS3 is installed, but I'd like to get a query without side effects (not even creating a temporary table). As a workaround I have opened the ":memory:" database, and issued the CREATE VIRTUAL TABLE

Change text_factory in Django/sqlite

大城市里の小女人 提交于 2019-12-05 08:17:25
I have a django project that uses a sqlite database that can be written to by an external tool. The text is supposed to be UTF-8, but in some cases there will be errors in the encoding. The text is from an external source, so I cannot control the encoding. Yes, I know that I could write a "wrapping layer" between the external source and the database, but I prefer not having to do this, especially since the database already contains a lot of "bad" data. The solution in sqlite is to change the text_factory to something like: lambda x: unicode(x, "utf-8", "ignore") However, I don't know how to

How to build sqlite for Python 2.4?

随声附和 提交于 2019-12-04 23:23:27
I would like to use pysqlite interface between Python and sdlite database. I have already Python and SQLite on my computer. But I have troubles with installation of pysqlite. During the installation I get the following error message: error: command 'gcc' failed with exit status 1 As far as I understood the problems appears because version of my Python is 2.4.3 and SQLite is integrated in Python since 2.5. However, I also found out that it IS possible to build sqlite for Python 2.4 (using some tricks, probably). Does anybody know how to build sqlite for Python 2.4? As another option I could try

Symbol not found: _sqlite3_enable_load_extension - sqlite installed via homebrew

旧街凉风 提交于 2019-12-04 05:05:18
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 running macOS 10.12.3 with Command Line Tools macOS 10.12, Xcode 8.2.1 I've installed pysqlite using pip (pysqlite 2.8.3) I have tried brew uninstall sqlite and brew uninstall python and reinstalling Adding these to my .bash_profile export PATH="$(brew --prefix sqlite)/bin:$PATH" LDFLAGS="-L/usr/local/opt/sqlite/lib" CPPFLAGS="-I/usr/local/opt/sqlite

Python SQLite: database is locked

前提是你 提交于 2019-12-03 17:54:04
问题 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.

Why can't pip uninstall pysqlite?

半城伤御伤魂 提交于 2019-12-03 11:09:13
问题 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 'pysqlite'. No files were found to uninstall. Nop, seems removed but still show up in pip freeze Now comes the fun $ pip install pysqlite Requirement already satisfied (use --upgrade to upgrade): pysqlite in /usr/lib/python2.6/dist-packages Cleaning

How to update a column in SQLite using pysqlite where I first needed to obtain a conditional value from other data in my table?

假如想象 提交于 2019-12-02 20:17:34
问题 So, I have the following issue when updating my database: I have a column in my table that I need to split in three essentially and so I have the following code: with con: cur = con.cursor() cur.execute('SELECT Column1 FROM MainTable') while True row = cur.fetchone() if row == None: break for line in row: a, b, c= line.split('-') print (b); which gives me the values of the second column for instance. However, I need to UPDATE that second column with those values and for this I have tried

Python pysqlite not accepting my qmark parameterization

瘦欲@ 提交于 2019-12-02 09:45:36
问题 I think I am being a bonehead, maybe not importing the right package, but when I do... from pysqlite2 import dbapi2 as sqlite import types import re import sys ... def create_asgn(self): stmt = "CREATE TABLE ? (login CHAR(8) PRIMARY KEY NOT NULL, grade INTEGER NOT NULL)" stmt2 = "insert into asgn values ('?', ?)" self.cursor.execute(stmt, (sys.argv[2],)) self.cursor.execute(stmt2, [sys.argv[2], sys.argv[3]]) ... I get the error pysqlite2.dbapi2.OperationalError: near "?": syntax error This

Python pysqlite not accepting my qmark parameterization

为君一笑 提交于 2019-12-02 05:32:40
I think I am being a bonehead, maybe not importing the right package, but when I do... from pysqlite2 import dbapi2 as sqlite import types import re import sys ... def create_asgn(self): stmt = "CREATE TABLE ? (login CHAR(8) PRIMARY KEY NOT NULL, grade INTEGER NOT NULL)" stmt2 = "insert into asgn values ('?', ?)" self.cursor.execute(stmt, (sys.argv[2],)) self.cursor.execute(stmt2, [sys.argv[2], sys.argv[3]]) ... I get the error pysqlite2.dbapi2.OperationalError: near "?": syntax error This makes very little sense to me, as the docs show that pysqlite is qmark parametrized. I am new to python