sqldict - you have a dict with unlimited capacity, what do you do? (it can store arbitrary objects as well)
Project description
sqldict - dict with sqlalchemy database-agnostic back-end
interface cleanup, numerous bugs fixed, and LOTS of testing added. You can now create a dict out of arbitrary key/value columns of any existing database table, in addition to ordinary dedicated strict or auto-pickling sqldicts.
>>> #d0 = sqldict("mysql://user:pass@dbhost/dbname", "table0", create=1) >>> engine = create_engine("sqlite://") >>> d1 = sqldict(engine, "table1", create=1) >>> d2 = sqldict(engine, "table2", create=1, valtype=Integer) >>> contents = {"asd":123} >>> d1.update(contents) >>> d2.update(contents) >>> assert d1["asd"] == "123" >>> assert d2["asd"] == 123>>> _ = engine.execute("create table asd (i integer, s varchar(50))") >>> _ = engine.execute("insert into asd values (42, 'gubbe')") >>> d3 = sqldict(engine, "asd", keycol="s", valcol="i") >>> d4 = sqldict(engine, "asd", keycol="i", valcol="s") >>> assert d3["gubbe"] == 42 >>> assert d4[42] == "gubbe"
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sqldict-0.4.0.tar.gz
(6.7 kB
view hashes)