diff options
author | Kali Kaneko <kali@leap.se> | 2013-05-30 04:35:35 +0900 |
---|---|---|
committer | Kali Kaneko <kali@leap.se> | 2013-05-30 04:35:35 +0900 |
commit | 51032d827b297e4ea0cd529d57d73cd44e0c3905 (patch) | |
tree | cc69775b399af33479bcf1e3a7dbaa68b932b8b0 /doc | |
parent | 06d9e5e7714562b10c48a0482dec2acd4abee55a (diff) |
cleanup docs
Diffstat (limited to 'doc')
38 files changed, 12 insertions, 783 deletions
diff --git a/doc/includes/sqlite3/adapter_datetime.py b/doc/includes/sqlite3/adapter_datetime.py deleted file mode 100644 index 5a43b02..0000000 --- a/doc/includes/sqlite3/adapter_datetime.py +++ /dev/null @@ -1,14 +0,0 @@ -from pysqlite2 import dbapi2 as sqlite3 -import datetime, time - -def adapt_datetime(ts): - return time.mktime(ts.timetuple()) - -sqlite3.register_adapter(datetime.datetime, adapt_datetime) - -con = sqlite3.connect(":memory:") -cur = con.cursor() - -now = datetime.datetime.now() -cur.execute("select ?", (now,)) -print cur.fetchone()[0] diff --git a/doc/includes/sqlite3/adapter_point_1.py b/doc/includes/sqlite3/adapter_point_1.py deleted file mode 100644 index d9acb8d..0000000 --- a/doc/includes/sqlite3/adapter_point_1.py +++ /dev/null @@ -1,16 +0,0 @@ -from pysqlite2 import dbapi2 as sqlite3 - -class Point(object): - def __init__(self, x, y): - self.x, self.y = x, y - - def __conform__(self, protocol): - if protocol is sqlite3.PrepareProtocol: - return "%f;%f" % (self.x, self.y) - -con = sqlite3.connect(":memory:") -cur = con.cursor() - -p = Point(4.0, -3.2) -cur.execute("select ?", (p,)) -print cur.fetchone()[0] diff --git a/doc/includes/sqlite3/adapter_point_2.py b/doc/includes/sqlite3/adapter_point_2.py deleted file mode 100644 index 6ec58a8..0000000 --- a/doc/includes/sqlite3/adapter_point_2.py +++ /dev/null @@ -1,17 +0,0 @@ -from pysqlite2 import dbapi2 as sqlite3 - -class Point(object): - def __init__(self, x, y): - self.x, self.y = x, y - -def adapt_point(point): - return "%f;%f" % (point.x, point.y) - -sqlite3.register_adapter(Point, adapt_point) - -con = sqlite3.connect(":memory:") -cur = con.cursor() - -p = Point(4.0, -3.2) -cur.execute("select ?", (p,)) -print cur.fetchone()[0] diff --git a/doc/includes/sqlite3/apsw_example.py b/doc/includes/sqlite3/apsw_example.py deleted file mode 100644 index bdca0c9..0000000 --- a/doc/includes/sqlite3/apsw_example.py +++ /dev/null @@ -1,12 +0,0 @@ -from pysqlite2 import dbapi2 as sqlite3 -import apsw - -apsw_con = apsw.Connection(":memory:") -apsw_con.createscalarfunction("times_two", lambda x: 2*x, 1) - -# Create pysqlite connection from APSW connection -con = sqlite3.connect(apsw_con) -result = con.execute("select times_two(15)").fetchone()[0] -assert result == 30 -con.close() - diff --git a/doc/includes/sqlite3/authorizer.py b/doc/includes/sqlite3/authorizer.py deleted file mode 100644 index 0176c6c..0000000 --- a/doc/includes/sqlite3/authorizer.py +++ /dev/null @@ -1,26 +0,0 @@ -from pysqlite2 import dbapi2 as sqlite3 - -def authorizer_callback(action, arg1, arg2, dbname, source): - if action != sqlite3.SQLITE_SELECT: - return sqlite3.SQLITE_DENY - if arg1 == "private_table": - return sqlite3.SQLITE_DENY - return sqlite3.SQLITE_OK - -con = sqlite3.connect(":memory:") -con.executescript(""" - create table public_table(c1, c2); - create table private_table(c1, c2); - """) -con.set_authorizer(authorizer_callback) - -try: - con.execute("select * from private_table") -except sqlite3.DatabaseError, e: - print "SELECT FROM private_table =>", e.args[0] # access ... prohibited - -try: - con.execute("insert into public_table(c1, c2) values (1, 2)") -except sqlite3.DatabaseError, e: - print "DML command =>", e.args[0] # access ... prohibited - diff --git a/doc/includes/sqlite3/collation_reverse.py b/doc/includes/sqlite3/collation_reverse.py deleted file mode 100644 index 100fac9..0000000 --- a/doc/includes/sqlite3/collation_reverse.py +++ /dev/null @@ -1,15 +0,0 @@ -from pysqlite2 import dbapi2 as sqlite3 - -def collate_reverse(string1, string2): - return -cmp(string1, string2) - -con = sqlite3.connect(":memory:") -con.create_collation("reverse", collate_reverse) - -cur = con.cursor() -cur.execute("create table test(x)") -cur.executemany("insert into test(x) values (?)", [("a",), ("b",)]) -cur.execute("select x from test order by x collate reverse") -for row in cur: - print row -con.close() diff --git a/doc/includes/sqlite3/complete_statement.py b/doc/includes/sqlite3/complete_statement.py deleted file mode 100644 index 2bb49d4..0000000 --- a/doc/includes/sqlite3/complete_statement.py +++ /dev/null @@ -1,30 +0,0 @@ -# A minimal SQLite shell for experiments - -from pysqlite2 import dbapi2 as sqlite3 - -con = sqlite3.connect(":memory:") -con.isolation_level = None -cur = con.cursor() - -buffer = "" - -print "Enter your SQL commands to execute in SQLite." -print "Enter a blank line to exit." - -while True: - line = raw_input() - if line == "": - break - buffer += line - if sqlite3.complete_statement(buffer): - try: - buffer = buffer.strip() - cur.execute(buffer) - - if buffer.lstrip().upper().startswith("SELECT"): - print cur.fetchall() - except sqlite3.Error, e: - print "An error occurred:", e.args[0] - buffer = "" - -con.close() diff --git a/doc/includes/sqlite3/connect_db_1.py b/doc/includes/sqlite3/connect_db_1.py deleted file mode 100644 index 360bf21..0000000 --- a/doc/includes/sqlite3/connect_db_1.py +++ /dev/null @@ -1,3 +0,0 @@ -from pysqlite2 import dbapi2 as sqlite3 - -con = sqlite3.connect("mydb") diff --git a/doc/includes/sqlite3/connect_db_2.py b/doc/includes/sqlite3/connect_db_2.py deleted file mode 100644 index 6899843..0000000 --- a/doc/includes/sqlite3/connect_db_2.py +++ /dev/null @@ -1,3 +0,0 @@ -from pysqlite2 import dbapi2 as sqlite3 - -con = sqlite3.connect(":memory:") diff --git a/doc/includes/sqlite3/converter_point.py b/doc/includes/sqlite3/converter_point.py deleted file mode 100644 index 4ba0df5..0000000 --- a/doc/includes/sqlite3/converter_point.py +++ /dev/null @@ -1,47 +0,0 @@ -from pysqlite2 import dbapi2 as sqlite3 - -class Point(object): - def __init__(self, x, y): - self.x, self.y = x, y - - def __repr__(self): - return "(%f;%f)" % (self.x, self.y) - -def adapt_point(point): - return "%f;%f" % (point.x, point.y) - -def convert_point(s): - x, y = map(float, s.split(";")) - return Point(x, y) - -# Register the adapter -sqlite3.register_adapter(Point, adapt_point) - -# Register the converter -sqlite3.register_converter("point", convert_point) - -p = Point(4.0, -3.2) - -######################### -# 1) Using declared types -con = sqlite3.connect(":memory:", detect_types=sqlite3.PARSE_DECLTYPES) -cur = con.cursor() -cur.execute("create table test(p point)") - -cur.execute("insert into test(p) values (?)", (p,)) -cur.execute("select p from test") -print "with declared types:", cur.fetchone()[0] -cur.close() -con.close() - -####################### -# 1) Using column names -con = sqlite3.connect(":memory:", detect_types=sqlite3.PARSE_COLNAMES) -cur = con.cursor() -cur.execute("create table test(p)") - -cur.execute("insert into test(p) values (?)", (p,)) -cur.execute('select p as "p [point]" from test') -print "with column names:", cur.fetchone()[0] -cur.close() -con.close() diff --git a/doc/includes/sqlite3/countcursors.py b/doc/includes/sqlite3/countcursors.py deleted file mode 100644 index 9ba7614..0000000 --- a/doc/includes/sqlite3/countcursors.py +++ /dev/null @@ -1,15 +0,0 @@ -from pysqlite2 import dbapi2 as sqlite3 - -class CountCursorsConnection(sqlite3.Connection): - def __init__(self, *args, **kwargs): - sqlite3.Connection.__init__(self, *args, **kwargs) - self.numcursors = 0 - - def cursor(self, *args, **kwargs): - self.numcursors += 1 - return sqlite3.Connection.cursor(self, *args, **kwargs) - -con = sqlite3.connect(":memory:", factory=CountCursorsConnection) -cur1 = con.cursor() -cur2 = con.cursor() -print con.numcursors diff --git a/doc/includes/sqlite3/createdb.py b/doc/includes/sqlite3/createdb.py deleted file mode 100644 index 28e9514..0000000 --- a/doc/includes/sqlite3/createdb.py +++ /dev/null @@ -1,28 +0,0 @@ -# Not referenced from the documentation, but builds the database file the other -# code snippets expect. - -from pysqlite2 import dbapi2 as sqlite3 -import os - -DB_FILE = "mydb" - -if os.path.exists(DB_FILE): - os.remove(DB_FILE) - -con = sqlite3.connect(DB_FILE) -cur = con.cursor() -cur.execute(""" - create table people - ( - name_last varchar(20), - age integer - ) - """) - -cur.execute("insert into people (name_last, age) values ('Yeltsin', 72)") -cur.execute("insert into people (name_last, age) values ('Putin', 51)") - -con.commit() - -cur.close() -con.close() diff --git a/doc/includes/sqlite3/ctx_manager.py b/doc/includes/sqlite3/ctx_manager.py deleted file mode 100644 index 2821e8f..0000000 --- a/doc/includes/sqlite3/ctx_manager.py +++ /dev/null @@ -1,19 +0,0 @@ -from __future__ import with_statement -from pysqlite2 import dbapi2 as sqlite3 - -con = sqlite3.connect(":memory:") -con.execute("create table person (id integer primary key, firstname varchar unique)") - -# Successful, con.commit() is called automatically afterwards -with con: - con.execute("insert into person(firstname) values (?)", ("Joe",)) - -# con.rollback() is called after the with block finishes with an exception, the -# exception is still raised and must be catched -try: - with con: - con.execute("insert into person(firstname) values (?)", ("Joe",)) -except sqlite3.IntegrityError: - print "couldn't add Joe twice" - - diff --git a/doc/includes/sqlite3/execsql_fetchonerow.py b/doc/includes/sqlite3/execsql_fetchonerow.py deleted file mode 100644 index e3aa578..0000000 --- a/doc/includes/sqlite3/execsql_fetchonerow.py +++ /dev/null @@ -1,17 +0,0 @@ -from pysqlite2 import dbapi2 as sqlite3 - -con = sqlite3.connect("mydb") - -cur = con.cursor() -SELECT = "select name_last, age from people order by age, name_last" - -# 1. Iterate over the rows available from the cursor, unpacking the -# resulting sequences to yield their elements (name_last, age): -cur.execute(SELECT) -for (name_last, age) in cur: - print '%s is %d years old.' % (name_last, age) - -# 2. Equivalently: -cur.execute(SELECT) -for row in cur: - print '%s is %d years old.' % (row[0], row[1]) diff --git a/doc/includes/sqlite3/execsql_printall_1.py b/doc/includes/sqlite3/execsql_printall_1.py deleted file mode 100644 index 62e48bd..0000000 --- a/doc/includes/sqlite3/execsql_printall_1.py +++ /dev/null @@ -1,13 +0,0 @@ -from pysqlite2 import dbapi2 as sqlite3 - -# Create a connection to the database file "mydb": -con = sqlite3.connect("mydb") - -# Get a Cursor object that operates in the context of Connection con: -cur = con.cursor() - -# Execute the SELECT statement: -cur.execute("select * from people order by age") - -# Retrieve all rows as a sequence and print that sequence: -print cur.fetchall() diff --git a/doc/includes/sqlite3/execute_1.py b/doc/includes/sqlite3/execute_1.py deleted file mode 100644 index 70967ea..0000000 --- a/doc/includes/sqlite3/execute_1.py +++ /dev/null @@ -1,11 +0,0 @@ -from pysqlite2 import dbapi2 as sqlite3 - -con = sqlite3.connect("mydb") - -cur = con.cursor() - -who = "Yeltsin" -age = 72 - -cur.execute("select name_last, age from people where name_last=? and age=?", (who, age)) -print cur.fetchone() diff --git a/doc/includes/sqlite3/execute_2.py b/doc/includes/sqlite3/execute_2.py deleted file mode 100644 index 416b116..0000000 --- a/doc/includes/sqlite3/execute_2.py +++ /dev/null @@ -1,12 +0,0 @@ -from pysqlite2 import dbapi2 as sqlite3 - -con = sqlite3.connect("mydb") - -cur = con.cursor() - -who = "Yeltsin" -age = 72 - -cur.execute("select name_last, age from people where name_last=:who and age=:age", - {"who": who, "age": age}) -print cur.fetchone() diff --git a/doc/includes/sqlite3/execute_3.py b/doc/includes/sqlite3/execute_3.py deleted file mode 100644 index 868be99..0000000 --- a/doc/includes/sqlite3/execute_3.py +++ /dev/null @@ -1,12 +0,0 @@ -from pysqlite2 import dbapi2 as sqlite3 - -con = sqlite3.connect("mydb") - -cur = con.cursor() - -who = "Yeltsin" -age = 72 - -cur.execute("select name_last, age from people where name_last=:who and age=:age", - locals()) -print cur.fetchone() diff --git a/doc/includes/sqlite3/executemany_1.py b/doc/includes/sqlite3/executemany_1.py deleted file mode 100644 index b076389..0000000 --- a/doc/includes/sqlite3/executemany_1.py +++ /dev/null @@ -1,24 +0,0 @@ -from pysqlite2 import dbapi2 as sqlite3 - -class IterChars: - def __init__(self): - self.count = ord('a') - - def __iter__(self): - return self - - def next(self): - if self.count > ord('z'): - raise StopIteration - self.count += 1 - return (chr(self.count - 1),) # this is a 1-tuple - -con = sqlite3.connect(":memory:") -cur = con.cursor() -cur.execute("create table characters(c)") - -theIter = IterChars() -cur.executemany("insert into characters(c) values (?)", theIter) - -cur.execute("select c from characters") -print cur.fetchall() diff --git a/doc/includes/sqlite3/executemany_2.py b/doc/includes/sqlite3/executemany_2.py deleted file mode 100644 index 9913909..0000000 --- a/doc/includes/sqlite3/executemany_2.py +++ /dev/null @@ -1,15 +0,0 @@ -from pysqlite2 import dbapi2 as sqlite3 - -def char_generator(): - import string - for c in string.letters[:26]: - yield (c,) - -con = sqlite3.connect(":memory:") -cur = con.cursor() -cur.execute("create table characters(c)") - -cur.executemany("insert into characters(c) values (?)", char_generator()) - -cur.execute("select c from characters") -print cur.fetchall() diff --git a/doc/includes/sqlite3/executescript.py b/doc/includes/sqlite3/executescript.py deleted file mode 100644 index 57c2613..0000000 --- a/doc/includes/sqlite3/executescript.py +++ /dev/null @@ -1,24 +0,0 @@ -from pysqlite2 import dbapi2 as sqlite3 - -con = sqlite3.connect(":memory:") -cur = con.cursor() -cur.executescript(""" - create table person( - firstname, - lastname, - age - ); - - create table book( - title, - author, - published - ); - - insert into book(title, author, published) - values ( - 'Dirk Gently''s Holistic Detective Agency', - 'Douglas Adams', - 1987 - ); - """) diff --git a/doc/includes/sqlite3/insert_more_people.py b/doc/includes/sqlite3/insert_more_people.py deleted file mode 100644 index 40600dc..0000000 --- a/doc/includes/sqlite3/insert_more_people.py +++ /dev/null @@ -1,16 +0,0 @@ -from pysqlite2 import dbapi2 as sqlite3 - -con = sqlite3.connect("mydb") - -cur = con.cursor() - -newPeople = ( - ('Lebed' , 53), - ('Zhirinovsky' , 57), - ) - -for person in newPeople: - cur.execute("insert into people (name_last, age) values (?, ?)", person) - -# The changes will not be saved unless the transaction is committed explicitly: -con.commit() diff --git a/doc/includes/sqlite3/load_extension.py b/doc/includes/sqlite3/load_extension.py deleted file mode 100644 index d8df90f..0000000 --- a/doc/includes/sqlite3/load_extension.py +++ /dev/null @@ -1,28 +0,0 @@ -from pysqlite2 import dbapi2 as sqlite3 - -con = sqlite3.connect(":memory:") - -# enable extension loading -con.enable_load_extension(True) - -# Load the fulltext search extension -con.execute("select load_extension('./fts3.so')") - -# alternatively you can load the extension using an API call: -# con.load_extension("./fts3.so") - -# disable extension laoding again -con.enable_load_extension(False) - -# example from SQLite wiki -con.execute("create virtual table recipe using fts3(name, ingredients)") -con.executescript(""" - insert into recipe (name, ingredients) values ('broccoli stew', 'broccoli peppers cheese tomatoes'); - insert into recipe (name, ingredients) values ('pumpkin stew', 'pumpkin onions garlic celery'); - insert into recipe (name, ingredients) values ('broccoli pie', 'broccoli cheese onions flour'); - insert into recipe (name, ingredients) values ('pumpkin pie', 'pumpkin sugar flour butter'); - """) -for row in con.execute("select rowid, name, ingredients from recipe where name match 'pie'"): - print row - - diff --git a/doc/includes/sqlite3/md5func.py b/doc/includes/sqlite3/md5func.py deleted file mode 100644 index 5b8b983..0000000 --- a/doc/includes/sqlite3/md5func.py +++ /dev/null @@ -1,11 +0,0 @@ -from pysqlite2 import dbapi2 as sqlite3 -import md5 - -def md5sum(t): - return md5.md5(t).hexdigest() - -con = sqlite3.connect(":memory:") -con.create_function("md5", 1, md5sum) -cur = con.cursor() -cur.execute("select md5(?)", ("foo",)) -print cur.fetchone()[0] diff --git a/doc/includes/sqlite3/mysumaggr.py b/doc/includes/sqlite3/mysumaggr.py deleted file mode 100644 index 4fbcad5..0000000 --- a/doc/includes/sqlite3/mysumaggr.py +++ /dev/null @@ -1,20 +0,0 @@ -from pysqlite2 import dbapi2 as sqlite3 - -class MySum: - def __init__(self): - self.count = 0 - - def step(self, value): - self.count += value - - def finalize(self): - return self.count - -con = sqlite3.connect(":memory:") -con.create_aggregate("mysum", 1, MySum) -cur = con.cursor() -cur.execute("create table test(i)") -cur.execute("insert into test(i) values (1)") -cur.execute("insert into test(i) values (2)") -cur.execute("select mysum(i) from test") -print cur.fetchone()[0] diff --git a/doc/includes/sqlite3/parse_colnames.py b/doc/includes/sqlite3/parse_colnames.py deleted file mode 100644 index 702fa8d..0000000 --- a/doc/includes/sqlite3/parse_colnames.py +++ /dev/null @@ -1,8 +0,0 @@ -from pysqlite2 import dbapi2 as sqlite3 -import datetime - -con = sqlite3.connect(":memory:", detect_types=sqlite3.PARSE_COLNAMES) -cur = con.cursor() -cur.execute('select ? as "x [timestamp]"', (datetime.datetime.now(),)) -dt = cur.fetchone()[0] -print dt, type(dt) diff --git a/doc/includes/sqlite3/progress.py b/doc/includes/sqlite3/progress.py deleted file mode 100644 index b30941d..0000000 --- a/doc/includes/sqlite3/progress.py +++ /dev/null @@ -1,29 +0,0 @@ -from pysqlite2 import dbapi2 as sqlite3 - -def progress(): - print "Query still executing. Please wait ..." - -con = sqlite3.connect(":memory:") -con.execute("create table test(x)") - -# Let's create some data -con.executemany("insert into test(x) values (?)", [(x,) for x in xrange(300)]) - -# A progress handler, executed every 10 million opcodes -con.set_progress_handler(progress, 10000000) - -# A particularly long-running query -killer_stament = """ - select count(*) from ( - select t1.x from test t1, test t2, test t3 - ) - """ - -con.execute(killer_stament) -print "-" * 50 - -# Clear the progress handler -con.set_progress_handler(None, 0) - -con.execute(killer_stament) - diff --git a/doc/includes/sqlite3/pysqlite_datetime.py b/doc/includes/sqlite3/pysqlite_datetime.py deleted file mode 100644 index 9075b46..0000000 --- a/doc/includes/sqlite3/pysqlite_datetime.py +++ /dev/null @@ -1,20 +0,0 @@ -from pysqlite2 import dbapi2 as sqlite3 -import datetime - -con = sqlite3.connect(":memory:", detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES) -cur = con.cursor() -cur.execute("create table test(d date, ts timestamp)") - -today = datetime.date.today() -now = datetime.datetime.now() - -cur.execute("insert into test(d, ts) values (?, ?)", (today, now)) -cur.execute("select d, ts from test") -row = cur.fetchone() -print today, "=>", row[0], type(row[0]) -print now, "=>", row[1], type(row[1]) - -cur.execute('select current_date as "d [date]", current_timestamp as "ts [timestamp]"') -row = cur.fetchone() -print "current_date", row[0], type(row[0]) -print "current_timestamp", row[1], type(row[1]) diff --git a/doc/includes/sqlite3/row_factory.py b/doc/includes/sqlite3/row_factory.py deleted file mode 100644 index bfbc64d..0000000 --- a/doc/includes/sqlite3/row_factory.py +++ /dev/null @@ -1,13 +0,0 @@ -from pysqlite2 import dbapi2 as sqlite3 - -def dict_factory(cursor, row): - d = {} - for idx, col in enumerate(cursor.description): - d[col[0]] = row[idx] - return d - -con = sqlite3.connect(":memory:") -con.row_factory = dict_factory -cur = con.cursor() -cur.execute("select 1 as a") -print cur.fetchone()["a"] diff --git a/doc/includes/sqlite3/rowclass.py b/doc/includes/sqlite3/rowclass.py deleted file mode 100644 index e210ef2..0000000 --- a/doc/includes/sqlite3/rowclass.py +++ /dev/null @@ -1,12 +0,0 @@ -from pysqlite2 import dbapi2 as sqlite3 - -con = sqlite3.connect("mydb") -con.row_factory = sqlite3.Row - -cur = con.cursor() -cur.execute("select name_last, age from people") -for row in cur: - assert row[0] == row["name_last"] - assert row["name_last"] == row["nAmE_lAsT"] - assert row[1] == row["age"] - assert row[1] == row["AgE"] diff --git a/doc/includes/sqlite3/shared_cache.py b/doc/includes/sqlite3/shared_cache.py deleted file mode 100644 index 98adf78..0000000 --- a/doc/includes/sqlite3/shared_cache.py +++ /dev/null @@ -1,6 +0,0 @@ -from pysqlite2 import dbapi2 as sqlite3 - -# The shared cache is only available in SQLite versions 3.3.3 or later -# See the SQLite documentaton for details. - -sqlite3.enable_shared_cache(True) diff --git a/doc/includes/sqlite3/shortcut_methods.py b/doc/includes/sqlite3/shortcut_methods.py deleted file mode 100644 index fcfc631..0000000 --- a/doc/includes/sqlite3/shortcut_methods.py +++ /dev/null @@ -1,21 +0,0 @@ -from pysqlite2 import dbapi2 as sqlite3 - -persons = [ - ("Hugo", "Boss"), - ("Calvin", "Klein") - ] - -con = sqlite3.connect(":memory:") - -# Create the table -con.execute("create table person(firstname, lastname)") - -# Fill the table -con.executemany("insert into person(firstname, lastname) values (?, ?)", persons) - -# Print the table contents -for row in con.execute("select firstname, lastname from person"): - print row - -# Using a dummy WHERE clause to not let SQLite take the shortcut table deletes. -print "I just deleted", con.execute("delete from person where 1=1").rowcount, "rows" diff --git a/doc/includes/sqlite3/simple_tableprinter.py b/doc/includes/sqlite3/simple_tableprinter.py deleted file mode 100644 index 2237dc5..0000000 --- a/doc/includes/sqlite3/simple_tableprinter.py +++ /dev/null @@ -1,26 +0,0 @@ -from pysqlite2 import dbapi2 as sqlite3 - -FIELD_MAX_WIDTH = 20 -TABLE_NAME = 'people' -SELECT = 'select * from %s order by age, name_last' % TABLE_NAME - -con = sqlite3.connect("mydb") - -cur = con.cursor() -cur.execute(SELECT) - -# Print a header. -for fieldDesc in cur.description: - print fieldDesc[0].ljust(FIELD_MAX_WIDTH) , -print # Finish the header with a newline. -print '-' * 78 - -# For each row, print the value of each field left-justified within -# the maximum possible width of that field. -fieldIndices = range(len(cur.description)) -for row in cur: - for fieldIndex in fieldIndices: - fieldValue = str(row[fieldIndex]) - print fieldValue.ljust(FIELD_MAX_WIDTH) , - - print # Finish the row with a newline. diff --git a/doc/includes/sqlite3/text_factory.py b/doc/includes/sqlite3/text_factory.py deleted file mode 100644 index cb38d52..0000000 --- a/doc/includes/sqlite3/text_factory.py +++ /dev/null @@ -1,42 +0,0 @@ -from pysqlite2 import dbapi2 as sqlite3 - -con = sqlite3.connect(":memory:") -cur = con.cursor() - -# Create the table -con.execute("create table person(lastname, firstname)") - -AUSTRIA = u"\xd6sterreich" - -# by default, rows are returned as Unicode -cur.execute("select ?", (AUSTRIA,)) -row = cur.fetchone() -assert row[0] == AUSTRIA - -# but we can make pysqlite always return bytestrings ... -con.text_factory = str -cur.execute("select ?", (AUSTRIA,)) -row = cur.fetchone() -assert type(row[0]) == str -# the bytestrings will be encoded in UTF-8, unless you stored garbage in the -# database ... -assert row[0] == AUSTRIA.encode("utf-8") - -# we can also implement a custom text_factory ... -# here we implement one that will ignore Unicode characters that cannot be -# decoded from UTF-8 -con.text_factory = lambda x: unicode(x, "utf-8", "ignore") -cur.execute("select ?", ("this is latin1 and would normally create errors" + u"\xe4\xf6\xfc".encode("latin1"),)) -row = cur.fetchone() -assert type(row[0]) == unicode - -# pysqlite offers a builtin optimized text_factory that will return bytestring -# objects, if the data is in ASCII only, and otherwise return unicode objects -con.text_factory = sqlite3.OptimizedUnicode -cur.execute("select ?", (AUSTRIA,)) -row = cur.fetchone() -assert type(row[0]) == unicode - -cur.execute("select ?", ("Germany",)) -row = cur.fetchone() -assert type(row[0]) == str diff --git a/doc/install-source.txt b/doc/install-source.txt deleted file mode 100644 index 90a3ce7..0000000 --- a/doc/install-source.txt +++ /dev/null @@ -1,147 +0,0 @@ -------------------------------------------------- -pysqlite installation guide - source distribution -------------------------------------------------- - -\(c\) 2005 Gerhard Häring - -Note: For Windows users, it is recommended that you use the win32 binary - distribution of pysqlite! - -Steps: - - - `Step 1: Satisfy the dependencies`_ - - `Step 2: Compile pysqlite`_ - - `Step 3: Install pysqlite`_ - - `Step 4: Test your pysqlite installation`_ - -Step 1: Satisfy The Dependencies -================================ - -pysqlite requires a valid combination of the dependencies in the list below. - -Detailed instructions on how to install each dependency are beyond the scope of -this document; consult the dependency distributor for installation -instructions. - -Dependencies: - - 1. Operating System and C Compiler - one of: - - * Linux/FreeBSD/NetBSD/OpenBSD and GCC - - * Other POSIX-compliant operating system and a C compiler - - 2. SQLite: - - * SQLite version 3.0.8 or later (as of pysqlite 2.2.0). This means we need - the SQLite library installed - either statically or dynamically linked - - and the SQLite header files. On Linux, the chances are very high that - your distribution offers packages for SQLite 3. Be sure to verify the - package is recent enough (version 3.0.8 or higher) and that you're - installing the development package as well, which will be need for - building pysqlite. On Debian and derivatives, the package to look for is - called libsqlite3-dev. - - 3. Python: - - * Python 2.3 or later - -Step 2: Compile pysqlite -======================== - -Once you have successfully installed the dependencies, you may proceed with the -installation of pysqlite itself. - -pysqlite has full support for the distutils_, the standard facility for Python -package distribution and installation. Full instructions for using the -distutils are available in `this section of the Python documentation`_, but you -can skip them unless you have an otherwise insoluble problem. - -Open a command prompt, change to the directory where you decompressed the -pysqlite source distribution, and type:: - - python setup.py build - -The installation script, setup.py, will attempt to automatically detect the -information needed by the C compiler; then it will invoke the distutils to -perform the actual compilation. If you installed automatic distributions of the -dependencies that place themselves in standard locations (on UNIX-style -operating systems), the compilation should proceed without incident. - -Otherwise you will have to customize the build process. That's what the file -*setup.cfg* is meant for. It's contains a few lines that you can customize so -your C compiler will find the library and header files and you can also do a -few other tweaks, like build pysqlite in debug mode. - -After you've customized *setup.cfg* appropriately, try invoking ``python -setup.py build`` again. - -If setup.py raises no errors and its output concludes with something like -"Creating library...", then you are ready to proceed to the next step. - -If you receive an error message from the compiler, then try to look at the -first error it reports. Other errors will most likely be aftereffects from the -first error (like not finding the sqlite3.h header file). - - -Step 3: Install pysqlite -======================== - -During this step, the setup script moves the *pysqlite2* package (including the -newly compiled C extension) to the standard package directory of your Python -installation so that Python will be able to import pysqlite2.dbapi2 and -pysqlite2.test. - -In addition to the Python code and shared library files actually used by the -Python interpreter, the setup script typically installs some supporting files, -such as documentation. Depending on your system configuration, these supporting -files may be placed in the same directory or a different directory from the -files used by the Python interpreter. - -Run the following command:: - - python setup.py install - -The setup script will install pysqlite, listing each file it installs. - -Errors during this step are rare because compilation (the finicky part of this -process) has already taken place; installation is really just a matter of -copying files. However, there will be file system permission errors if the -Python installation directory is not writable by the user running the setup -script. If you encounter such an error, try one of the following: - -- Log in as a user who has the required file system permissions and repeat the - installation step. -- Manually copy the directory build/lib.platform-pyver/pysqlite2 (which - contains the Python modules and compiled library files created during the - compilation step) to a directory in your PYTHONPATH. This approach will not - install the supporting files, but they are for the benefit of the programmer - rather than the Python interpreter anyway. - -Step 4: Test Your pysqlite Installation -======================================= - -Switch to a directory other than the temporary directory into which you -decompressed the source distribution (to avoid conflict between the copy of -pysqlite in that directory and the copy placed under the standard Python -site-packages directory), then run the pysqlite test suite by starting a Python -interpreter for the Python version you installed pysqlite for and entering the -following:: - - >>> from pysqlite2 import test - >>> test.test() - ..................................................................................................... - ---------------------------------------------------------------------- - Ran 101 tests in 0.182s - -If the test suite runs without any errors, you are finished. - -You should not encounter any errors at this stage since you have already -completed the compilation and installation steps successfully. If you do, -please report them to the `pysqlite bug tracker`_ or the `pysqlite mailing -list`_. - -.. _distutils: http://www.python.org/sigs/distutils-sig/ -.. _this section of the Python documentation: http://www.python.org/doc/current/inst/inst.html -.. _pysqlite bug tracker: http://pysqlite.googlecode.com/ -.. _pysqlite mailing list: http://itsystementwicklung.de/cgi-bin/mailman/listinfo/list-pysqlite diff --git a/doc/sphinx/conf.py b/doc/sphinx/conf.py index 6528513..8aee750 100644 --- a/doc/sphinx/conf.py +++ b/doc/sphinx/conf.py @@ -33,8 +33,8 @@ source_suffix = '.rst' master_doc = 'index' # General substitutions. -project = 'pysqlite' -copyright = u'2008-2009, Gerhard Häring' +project = 'pysqlcipher' +copyright = u'2008-2009, Gerhard Häring; 2013, Kali Kaneko' # The default replacements for |version| and |release|, also used in various # other places throughout the built documents. @@ -42,7 +42,7 @@ copyright = u'2008-2009, Gerhard Häring' # The short X.Y version. version = '2.6' # The full version, including alpha/beta/rc tags. -release = '2.6.0' +release = '2.6.0.dev1' # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: @@ -106,7 +106,7 @@ html_last_updated_fmt = '%b %d, %Y' #html_copy_source = True # Output file base name for HTML help builder. -htmlhelp_basename = 'pysqlitedoc' +htmlhelp_basename = 'pysqlcipherdoc' # Options for LaTeX output diff --git a/doc/sphinx/index.rst b/doc/sphinx/index.rst index 522f986..b48000d 100644 --- a/doc/sphinx/index.rst +++ b/doc/sphinx/index.rst @@ -2,8 +2,8 @@ You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. -Welcome to pysqlite's documentation! -==================================== +Welcome to pysqlcipher's documentation! +======================================= Contents: diff --git a/doc/sphinx/sqlite3.rst b/doc/sphinx/sqlcipher.rst index a0d5de8..7785aeb 100644 --- a/doc/sphinx/sqlite3.rst +++ b/doc/sphinx/sqlcipher.rst @@ -1,10 +1,12 @@ -:mod:`sqlite3` --- DB-API 2.0 interface for SQLite databases -============================================================ +:mod:`sqlcipher` --- DB-API 2.0 interface for SQCipher databases +============================================================== -.. module:: sqlite3 - :synopsis: A DB-API 2.0 implementation using SQLite 3.x. +.. module:: sqlcipher + :synopsis: A DB-API 2.0 implementation using SQCipher 3.x. .. sectionauthor:: Gerhard Häring <gh@ghaering.de> +.. sectionauthor:: Kali Kaneko <kali@leap.se> +.. note:: This documentation has to be adapted to the use of SQLCipher SQLite is a C library that provides a lightweight disk-based database that doesn't require a separate server process and allows accessing the database @@ -20,7 +22,6 @@ To use the module, you must first create a :class:`Connection` object that represents the database. Here the data will be stored in the :file:`/tmp/example` file:: - conn = sqlite3.connect('/tmp/example') You can also supply the special name ``:memory:`` to create a database in RAM. |