ulif.pynotify.sqlite – SQLite support

SQLite3 support for file walkers.

See: http://code.google.com/p/pysqlite/source/browse/misc/patterns.py?r=51ab37bca8bf1e56d18df81820e60bbc3aacf1ea

New in version 0.2.

class ulif.pynotify.sqlite.SQLiteFSWalker(connection_string=':memory:')

A file walker with SQLite support.

Different to base file walkers the SQLiteFSWalker stores results of filetree walks in a SQLite database. As a persistent file walker it can make assumptions about added and deleted files.

The database is opened using the given connection_string.

If you pass a path, the database will be created (if it does not exist yet) or reused.

In the database we use a table called filechanges which is expected to have the following format:

Column Type Attributes/Remarks
id integer primary key
path text Absolute path
status integer Filechange status
ts datetime Timestamp

Furthermore we create a unique index idx_path on path column and set the case_sensitive_like pragma to true, to get case-sensitive LIKE operators.

If the table does not exist already, it will be created on instantiation time of the class.

connection_string

The string to connect to SQLite DB

execute(cursor, statement, args=())

Execute the SQL statement with args on cursor.

Safe SQL execution of the given SQL statement. Performs a rollback if unsuccessful and always commits.

executescript(cursor, script)

Execute the SQL script with args on cursor.

walk(root_dir)

Walk the filetree rooted at root_dir and message changes.

Changes are files, modified in time elapsed since stored timestamp of root_dir (ulif.pynotify.MODIFIED), files that are not yet in the database (ulif.pynotify.ADDED), and files that were in the database but cannot be found in filesystem anymore (ulif.pynotify.DELETED),.

Returns a generator of tuples, containing FSChange objects and a timestamp as datetime.datetime object, giving the datetime of last modification (if ADDED or MODIFIED) or current datetime (if DELETED).

The root_dir, despite of its name can also be a regular file.

getTimeStamp(path)

Get timestamp for path.

Returns modification time of path as datetime.datetime object.

Previous topic

ulif.pynotify.base – Base components

Next topic

ulif.pynotify.ui – UI components

This Page