{"id":28559155,"url":"https://github.com/toastdriven/friendlydb","last_synced_at":"2025-06-10T08:36:19.596Z","repository":{"id":2176334,"uuid":"3123260","full_name":"toastdriven/friendlydb","owner":"toastdriven","description":"A small \u0026 fast following/followers database written in Python.","archived":false,"fork":false,"pushed_at":"2013-12-03T09:47:23.000Z","size":123,"stargazers_count":41,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-07T16:54:57.039Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/toastdriven.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-01-07T06:01:11.000Z","updated_at":"2021-07-06T19:54:21.000Z","dependencies_parsed_at":"2022-07-21T22:48:24.695Z","dependency_job_id":null,"html_url":"https://github.com/toastdriven/friendlydb","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toastdriven%2Ffriendlydb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toastdriven%2Ffriendlydb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toastdriven%2Ffriendlydb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toastdriven%2Ffriendlydb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/toastdriven","download_url":"https://codeload.github.com/toastdriven/friendlydb/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toastdriven%2Ffriendlydb/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259039643,"owners_count":22796880,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-10T08:36:09.970Z","updated_at":"2025-06-10T08:36:19.573Z","avatar_url":"https://github.com/toastdriven.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"==========\nFriendlyDB\n==========\n\n``friendlydb`` is a small \u0026 fast following/followers database written in\nPython. It can be either used directly from your Python code or over HTTP\nwith small web API.\n\nFriendlyDB isn't meant to be a full user system; it should be used to augment\nan existing system to track relationships.\n\n\nWARNING\n=======\n\nStarting with v2.0.0, FriendlyDB is **NOT** backward-compatible with v0.4.0 \u0026\nbefore. Prior to v2.0.0, data was stored on the filesystem, but in v2.0.0 \u0026\nlater, data is stored in Redis.\n\nIt was rewritten to use Redis for several reasons:\n\n* Better performance\n* Less wear/tear on hard disks\n* Simpler code\n\nHowever, this does mean you will need to run your own version of the Redis\nserver (2.6.4+ recommended).\n\nSee below if you need to migrate from an older install to v2.0.0.\n\n\nUsage\n=====\n\nUsing FriendlyDB from Python looks like::\n\n    from friendlydb.db import FriendlyDB\n\n    # Start using the DB (assumes Redis default host/port/db).\n    fdb = FriendlyDB()\n    # Alternatively, ``fdb = FriendlyDB(host='127.0.0.2', port=7100, db=3)``\n\n    # Grab a user by their username.\n    daniel = fdb['daniel']\n\n    # Follow a couple users.\n    daniel.follow('alice')\n    daniel.follow('bob')\n    daniel.follow('joe')\n\n    # Check the following.\n    daniel.following()\n    # Returns:\n    # [\n    #     'alice',\n    #     'bob',\n    #     'joe',\n    # ]\n\n    # Check joe's followers.\n    fdb['joe'].followers()\n    # Returns:\n    # [\n    #     'daniel',\n    # ]\n\n    # Unfollow.\n    daniel.unfollow('bob')\n\n    # Check the following.\n    daniel.following()\n    # Returns:\n    # [\n    #     'alice',\n    #     'joe',\n    # ]\n\n    # Dust off \u0026 nuke everything from orbit.\n    fdb.clear()\n\nUsing FriendlyDB from HTTP looks like (all trailing slashes are optional)::\n\n    # In one shell, start the server.\n    python friendlydb/server.py -d /tmp/friendly\n\n    # From another, run some URLs.\n    curl -X GET http://127.0.0.1:8008/\n    # {\"version\": \"0.3.0\"}\n\n    curl -X GET http://127.0.0.1:8008/daniel/\n    # {\"username\": \"daniel\", \"following\": [], \"followers\": []}\n\n    curl -X POST http://127.0.0.1:8008/daniel/follow/alice/\n    # {\"username\": \"daniel\", \"other_username\": \"alice\", \"followed\": true}\n    curl -X POST http://127.0.0.1:8008/daniel/follow/bob/\n    # {\"username\": \"daniel\", \"other_username\": \"bob\", \"followed\": true}\n    curl -X POST http://127.0.0.1:8008/daniel/follow/joe/\n    # {\"username\": \"daniel\", \"other_username\": \"joe\", \"followed\": true}\n\n    curl -X POST http://127.0.0.1:8008/daniel/unfollow/joe/\n    # {\"username\": \"daniel\", \"other_username\": \"joe\", \"unfollowed\": true}\n\n    curl -X GET http://127.0.0.1:8008/daniel/\n    # {\"username\": \"daniel\", \"following\": [\"alice\", \"bob\"], \"followers\": []}\n\n    curl -X GET http://127.0.0.1:8008/daniel/is_following/alice/\n    # {\"username\": \"daniel\", \"other_username\": \"alice\", \"is_following\": true}\n\n    curl -X GET http://127.0.0.1:8008/alice/is_followed_by/daniel/\n    # {\"username\": \"alice\", \"other_username\": \"daniel\", \"is_followed_by\": true}\n\n    curl -X GET http://127.0.0.1:8008/alice/is_followed_by/joe/\n    # {\"username\": \"alice\", \"other_username\": \"joe\", \"is_followed_by\": false}\n\n\nRequirements\n============\n\n* Python 2.6+ or Python 3.3+\n* redis.py \u003e= 2.7.2\n* (Optional) gevent for the HTTP server\n* (Optional) unittest2 for running tests\n\n\nInstallation\n============\n\nUsing pip, you can install it with ``pip install friendlydb``.\n\n\nPerformance\n===========\n\nYou can scope out FriendlyDB's performance for yourself by running the\nincluded ``benchmark.py`` script.\n\nIn tests on a 2011 MacBook Pro (i7), the benchmark script demonstrated:\n\n* created 1,000,000 relationships between 10,000 users: 179 seconds (~2.5X faster than 0.4.0)\n* avg time to fetch a user's followers: 0.0016 seconds\n* never exceeding 41Mb of RAM RSS\n\n\nMigrating from v0.4.0 to 2.0.0\n==============================\n\nFirst, install \u0026 run the Redis server.\n\nSecond, run ``pip install redis\u003e=2.7.2``.\n\nTo migrate your data, the easiest way is to leave your old install of FriendlyDB\nin place (using the HTTP server), create a new install w/ Redis, then run\ncode like::\n\n    import requests\n    import json\n    # The new version.\n    from friendlydb import FriendlyDB\n\n    old_url = 'http://127.0.0.1:8008/'\n    fdb = FriendlyDB()\n\n    for username in users:\n        user = fdb[username]\n\n        # Following.\n        resp = requests.get(\"{0}/{1}/following/\".format(old_url, username))\n        data = json.loads(resp.content)\n\n        for f_username in data.get(\"following\", []):\n            user.follow(f_username)\n\nYou should create your own script \u0026 verify your data post-migration. No promises\nare made about the effectiveness/accuracy of the above code.\n\n\nRunning Tests\n=============\n\n``friendlydb`` is maintained with passing tests at all times. Simply run::\n\n    python -m unittest2 tests\n\n\nContributions\n=============\n\nIn order for a contribution to be considered for merging, it must meet the\nfollowing requirements:\n\n* Patch cleanly solves the problem\n* Added test coverage (now passing) to expose the bug \u0026 check for regression\n* If the behavior affects end-users, there must be docs on the changes\n* The patch/tests must be compatibly licensed with New BSD\n\nThe best way to submit contributions is by forking the project on Github,\napplying your changes *on a new branch*, pushing those changes back to GH \u0026\nsubmitting a pull request through the GitHub interface.\n\n\nLicense\n=======\n\nNew BSD license.\n\n:author: Daniel Lindsley\n:version: 2.0.0\n:date: 2013-01-17\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoastdriven%2Ffriendlydb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftoastdriven%2Ffriendlydb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoastdriven%2Ffriendlydb/lists"}