This post originated from an RSS feed registered with Python Buzz
by Ng Pheng Siong.
Original Post: PySQLcrypt
Feed Title: (render-blog Ng Pheng Siong)
Feed URL: http://sandbox.rulemaker.net/ngps/rdf10_xml
Feed Description: Just another this here thing blog.
First, copy _pysqlcrypt.pyd and sqlcrypt/*.py into your Python installation's
site-packages.
Next, run the unit tests in crypt_test.py:
C:\> python crypt_test.py
.........
----------------------------------------------------------------------
Ran 9 tests in 0.660s
OK
Now try out crypt_dbapi_txns.py. This program is based on
dbapi_transactions.py from PySQLite, with the following changes: (1) the database file, 'customerdb', is encrypted; (2) at the end of the program run, the database content is not cleared.
C:\> python crypt_dbapi_txns.py
C:\> sqlcrypt3 customerdb
SQLcrypt version 3.0.7
Enter ".help" for instructions
sqlcrypt> .decrypt abcdefgh
sqlcrypt> .tables
customer orders
sqlcrypt> select * from customer;
1|Jane|Doe|JD0001
sqlcrypt> select * from orders;
1|1|White Towel|2
2|1|Blue Cup|5
sqlcrypt> ^Z
C:\> sqlite3 customerdb "select * from orders"
SQL error: file is encrypted or is not a database
C:\> python
Python 2.3.4 (#53, May 25 2004, 21:17:02) [MSC v.1200 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlcrypt
>>> sqlcrypt.license_key('ZIHKBLID-IACHUSSU-JUPOTCNF-CXYOQSFE')
>>> cnx = sqlcrypt.connect('customerdb')
>>> cnx.passphrase('abcdefgh', 0)
>>> cu = cnx.cursor()
>>> cu.execute('select * from orders')
>>> print cu.fetchall()
[(1, 1, 'White Towel', 2), (2, 1, 'Blue Cup', 5)]
>>>