added example with object-oriented API to readme

This commit is contained in:
Gregor Aisch 2013-04-01 14:07:31 +02:00
parent b7bef6ddc4
commit d0155938d1

View File

@ -45,6 +45,19 @@ Another example, updating data in a datastore, might look like this:
upsert(engine, table, item, ['key1', 'key2']) upsert(engine, table, item, ['key1', 'key2'])
Here's the same example, but using the object-oriented API:
import sqlaload
db = sqlaload.create('sqlite:///things.db')
table = db.get_table('data')
for item in magic_data_source_that_produces_entries():
assert 'key1' in item
assert 'key2' in item
table.upsert(item, ['key1', 'key2'])
Functions Functions
--------- ---------
@ -74,6 +87,7 @@ The library currently exposes the following functions:
* ``delete(engine, table, **kw)`` will remove records from a table. ``**kw`` is the same as in ``find`` and can be used to limit the set of records to be removed. * ``delete(engine, table, **kw)`` will remove records from a table. ``**kw`` is the same as in ``find`` and can be used to limit the set of records to be removed.
Feedback Feedback
-------- --------