Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fourcube/gf-db-wrapper
https://github.com/fourcube/gf-db-wrapper
Last synced: 4 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/fourcube/gf-db-wrapper
- Owner: fourcube
- Created: 2016-01-10T13:46:38.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-01-10T13:46:48.000Z (about 9 years ago)
- Last Synced: 2024-12-22T19:07:37.482Z (29 days ago)
- Language: Python
- Size: 1000 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# gutefrage-db-wrapper
## Dependencies
```
$ pip install redis
```Also requires a redis instance (http://redis.io) running on localhost. You can install docker (http://docker.io) and then run `./start_redis.sh`.
## Usage
```python
import db# Connect to local redis instance
r = db.connect()# Write a question to the database
new_question = {
"title": "Question?",
"text": "Text..."
}
q = db.store_question(r, new_question)
# Question now has an 'id'
print q["id"]# Load a random question from the database
q = db.random_question(r)
print q# Vote for a question
q = db.vote_question(r, q["id"])
print q.votes# Get a list of all questions
qs = db.list_questions(r)
print qs```