priitj / whitedb

WhiteDB memory database
http://whitedb.org/
GNU General Public License v3.0
608 stars 78 forks source link

Python installation on windows #16

Closed pythonmobile closed 10 years ago

pythonmobile commented 10 years ago

Can we please get pip/easy_install support on windows, preferably with pre-compiled libraries so that the setup does not need Visual C++ compiler setup.

Also:

  1. After compiling on windows with python 2.7.3, I get this when I run tests.py:

................wg data handling error: wrong field number given to wg_set_field

.

Ran 17 tests in 1.137s

OK

  1. Is there a python example somewhere that uses whitedb as a key, value store like Redis (preferably using whitedb.py). I currently use Redis on a single node, and am trying to see if I can use whitedb.
priitj commented 10 years ago

Regarding the Python installation: I'll just note for future reference that open issues #4 and #13 are also related. We'll need to discuss internally how high a priority this should be before I can comment any further.

The error output of the unit tests is generated by the wgdb library. It is supposed to do it in this case. The test is checking whether an error is raised on invalid input. The library level error messages can be suppressed, if they become annoying. Generally this is not an issue in a user application.

I can't think of any key-value example available online. Off the top of my head, I'd create an index on column 0 using indextool, then add data using d.insert((key, value)) and find it using

c=d.cursor()
c.execute(matchrec=[key])
c.fetchone()[1]

where d is the database object.

priitj commented 10 years ago

I should probably add that the above example does not make sure the keys are unique. So a slightly improved version would be something like this:

def kvget(d, k):
    c=d.cursor()
    c.execute(matchrec=[k])
    r=c.fetchone()
    c.close()
    if r is None: return None
    else: return r[1]

def kvset(d, k, v):
    c=d.cursor()
    c.execute(matchrec=[k])
    r=c.fetchone()
    c.close()
    if r is None: d.insert((k, v))
    else: r[1]=v
pythonmobile commented 10 years ago

@priitj Thanks.