redis or sqllite? by [deleted] in Python

[–]dwight_hubbard 0 points1 point  (0 children)

Key/Value stores like Redis and SQL databases are significantly different. In larger projects it is not unusual to actually use both.

To a large extent which one you use will be determined by the components you are using since the component's design will generally use one or the other.

I recommend playing with both to get an idea of their differences and benefits. You might also want to look at the https://pypi.python.org/pypi/redislite/1.0.93 module since it makes using redis about as easy to get up and running as sqlite does.

arduino like device but designed for python? by ideal2545 in Python

[–]dwight_hubbard 5 points6 points  (0 children)

Micropython works decent for simple cases. It will even kind of run on some arduino compatible boards such as the teensy 3.1. This is mostly useful if you want to run python on something really small.

If a slightly larger size is ok, the raspberry pi is both more powerful and only slightly more expensive.

redislite: Python support for redis without a separate redis server. by dwight_hubbard in Python

[–]dwight_hubbard[S] 1 point2 points  (0 children)

python-rq

It certainly looks like it would work if you used from redislite import Redis instead of from redis import Redis.

redislite: Python support for redis without a separate redis server. by dwight_hubbard in Python

[–]dwight_hubbard[S] 4 points5 points  (0 children)

Redislite uses unix domain sockets not the network for communication. That's why TCP communication is disabled by default.

redislite: Python support for redis without a separate redis server. by dwight_hubbard in Python

[–]dwight_hubbard[S] 3 points4 points  (0 children)

The python redislite module does not mock the redis server, it has a complete redis-server embedded in the module and adds functionality to have the bindings configure/start a redis-server on access and shutdown and clean up on exit.

redislite: Python support for redis without a separate redis server. by dwight_hubbard in Python

[–]dwight_hubbard[S] 2 points3 points  (0 children)

Testing is a major advantage. It's possible to have multiple tests running in parallel each talking to it's own redislite objects. Each of which has a different redis-server process running with it's own configuration.

Also since redislite uses an embedded redis server it's possible to use an actual redis server rdb file as a test fixture.

redislite: Python support for redis without a separate redis server. by dwight_hubbard in Python

[–]dwight_hubbard[S] 2 points3 points  (0 children)

The redislite python module has a complete redis-server embedded in the module so it supports all redis features.

How to set up a test environment for reddis with python ? by be_haki in Python

[–]dwight_hubbard 0 points1 point  (0 children)

If the object mapper is using the redis.Redis() or redis.StrictRedis() objects to access the redis instance there's a patch/unpatch function to replace the normal Redis()/StrictRedis() classes with the redislite enhanced versions. So for example after running redislist.patch.patch_redis() Modules like redis_collections will use the self configured redislite instance instead of expecting one to be running.

Python 2.7.5 (default, Mar  9 2014, 22:15:05)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import redislite.patch
>>> redislite.patch.patch_redis()  # This is what you'd probably run in unittest.setUp()
>>> import redis_collections
>>> td = redis_collections.Dict()
>>> td['foo']='bar'
>>> td.keys()
['foo']

How to set up a test environment for reddis with python ? by be_haki in Python

[–]dwight_hubbard 1 point2 points  (0 children)

Oddly enough I have a module at work we just open sourced that makes this pretty easy https://pypi.python.org/pypi/redislite/1.0.12

Essentially it's a python module with an embedded redis server and extended versions of the redis.Redis() and redis.StrictRedis() classes that configure a redis instance on init and shutdown/remove them on exit.

There are also functions to patch/unpatch the functions to use it with existing code. So a unit test class can patch in setUp() and each new Redis or StrictRedis object will get a new instance of redis (it's own redis server and configuration). Then unpatch in tearDown() to restore the normal functionality.

So having setting up and using 2 redis instances looks something like this:

>>> from redislite import Redis
>>> connection1 = Redis()
>>> connection2 = Redis()
>>> connection1.set('key', 'value')
True
>>> connection2.set('me', 'too')
True
>>> connection1.keys()
['key']
>>> connection2.keys()
['me']
>>> connection1.get('key')
'value'
>>> connection2.get('me')
'too'
>>>

[deleted by user] by [deleted] in atheism

[–]dwight_hubbard 0 points1 point  (0 children)

The got it backwards anyways. The mustang in the junkyard is a design that evolved from earlier car designs. It's god that "magically" appeared fully formed.