pysqlite

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 bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_facto...

Override DEFINEs in setup.cfg in source eggs

The source egg of PySQLite 2.6.0 contains a file setup.cfg that looks like this: [build_ext] #define= #include_dirs=/usr/local/include #library_dirs=/usr/local/lib libraries=sqlite3 define=SQLITE_OMIT_LOAD_EXTENSION I'd like to build the egg with the SQLITE_OMIT_LOAD_EXTENSION define disabled (not set). I could do that by uncommenting...

sqlite usages and propsure

Could someone provide an examples about why sqlite db is needed and for which propuses , especially if it can be used by security application ? ...

Pysqlite setup error

When intalling pysqlite on my Mac I get permission denied when it tries to create pysqlite2-doc dir. Any ideas why? Tia, FR ...

atomic read from sqlite database while it is being written to

Is it possible to read from a sqlite database while it is being written to? How would one go about accomplishing this? Thanks! ...

Checking duplicate while inserting in SQLite

Hello All, I am trying to insert a data into SQLite database using Python. INSERT INTO DATA_TABLE(UID,LABEL) VALUES (NULL, "UK") WHERE "UK" NOT EXISTS IN (SELECT LABEL FROM DATA_TABLE); This query is dynamically generated from Python and I am checking whether the date is already exist in the table before inserting and its not w...

pysqlite - how to save images.

Hello, 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. ...

"%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 thing But, I've thought the first and second is the same. What are the differences between tho...

How expensive sqlite3.connect and close in SQLite?

I use connect() and cursor() for using SQLite self.connector = sqlite3.connect(self.dbFile) self.cursor = self.connector.cursor() And close() for stop using it. self.cursor.close() How expensive (in terms of processing time) are they? Is it so expensive that it's necessary to use it only absolutely necessary? Or, is it just OK to...

'from sqlite3 import dbapi2 as sqlite3' vs 'import sqlite3'?

When I see the examples for pysqlite, there are two use cases for the SQLite library. from sqlite3 import dbapi2 as sqlite3 and import sqlite3 Why there are two ways to support the sqlite3 api? What's the difference between the two? Are they the same? In normal use, which would be preferred. ADDED I knew that they are different ...

The open/close function of SQLite implementation

I'm trying to come up with SQLiteDB object, and following is the open/close code for it. Does this work without problem? Am I missing something important? For close(), I use con.close() and cursor.close(), but I'm wondering if cursor.close() is necessary. class SQLiteDB(object): def __init__(self, dbFile, connect = True): ...

Reproduce pysqlite's row_factory on apsw

I have been trying to migrate away from pysqlite to apsw but I can't find a way to reproduce its row_factory function. this is my original code: connection = sqlite3.connect("db.db3") connection.row_factory = sqlite3.Row cursor = connection.cursor() and I use it like this: query = """ SELECT wbcode, Year, """+query_name+""" ...

python and sqlite - escape input

Hi there, Using python with a sqlite DB - whats the method used for escaping the data going out and pulling the data coming out? Using pysqlite2 Google has conflicting suggestions. ...