GredisQL
A GraphQL interface for Redis Database.
Version Information
Current Version: 0.0.9
Update History
Version 0.0.9 (Latest)
- Added support for Redis Sorted Sets operations
- Added support for Redis Hash operations
- Improved type handling for GraphQL responses
- Fixed GraphQL schema type definitions
- Added comprehensive test suite
Version 0.0.8
- Added support for Redis List operations
- Added support for Redis Set operations
- Improved error handling
Version 0.0.7
- Initial release with basic Redis operations
- Support for String operations
- Basic GraphQL interface implementation
How To Install
pip install gredisql
If you find this project interesting, you can always appreciate it by giving it a Star. :D
A Background of GredisQL
Motivation
- I was bored, been sick for a while, had to lie on the bed. So I needed to create something.
- Redis has Web interface ( actually a REST interface), so I urged to build one in GraphQL.
- There are some pretty amazing GraphQL libraries around python echo system, I wanted to try them.
- Last but not least, jump into quick coding session, engage and nurture the human mind. LOL
Design Philosophy
- All the data
mutationandqueryare not separated here by action and most probably all the actions are performed viaqueryoperation. - Technically
allthe requests sent to the GraphQLserverwas inPOST, so I was initially okay with the implementation. Strawberry-Graphqlis kind of server agnostic so either you can useASGIorWSGIcounterpart.- Currently limiting the implementation with
WSGIserver, but I've plan to adoptASGIin the journey, to supportsubscription. - Not
allRedis commands are found in the implementation, I'll try to cover it in the process.
Inspiration and Tools I used
redis==5.0.0is used to communicate with the Redis database.strawberry-graphqlis used to do the heavy lifting. Also, I triedariadnewhich is also another cool tool to try with.
Features and Future Plans
-
String Commands
- GET, SET, MSET, MGET
- INCRBY, DECRBY, INCRBYFLOAT
- APPEND, GETEX, GETDEL
- EXPIRE, EXPIREAT
- KEYS, EXISTS, DELETE
-
List Commands
- LPUSH, RPUSH
- LPOP, RPOP
- LRANGE
- LLEN
-
Set Commands
- SADD, SCARD
- SDIFF, SDIFFSTORE
- SINTER, SINTERSTORE
- SISMEMBER, SMEMBERS
- SMOVE, SPOP
-
Hash Commands
- HSET, HGET
- HGETALL
- HDEL
- HLEN
- HKEYS, HVALS
-
Sorted Set Commands
- ZADD
- ZRANGE, ZREVRANGE
- ZCARD
- ZSCORE
- ZREM
- ZCOUNT
And many more to come in the future iteration.
Example GraphQL Queries
String Operations
query {
set(name: "mykey", value: "myvalue")
get(name: "mykey")
mset(
mappings: [
{ key: "key1", value: "value1" }
{ key: "key2", value: "value2" }
]
)
mget(keys: ["key1", "key2"])
}
List Operations
query {
lpush(name: "mylist", values: ["one", "two", "three"])
lrange(name: "mylist", start: 0, end: -1)
llen(name: "mylist")
}
Hash Operations
query {
hset(name: "myhash", key: "field1", value: "value1")
hget(name: "myhash", key: "field1")
hgetall(name: "myhash")
}
Sorted Set Operations
query {
zadd(name: "myset", mapping: {"member1": 1.0, "member2": 2.0})
zrange(name: "myset", start: 0, end: -1, withscores: true)
zcard(name: "myset")
}
Quick Starting the GraphQL Server
if __name__ == "__main__":
from gredisql.core import Server
server = Server()
server.run()
You can specify the host, port and debug mode in while instantiating the GraphQL server.
Simply write,
if __name__ == "__main__":
REDIS_HOST = 'redis-4343.c8.us-east-1-4.ec2.cloud.redislabs.com'
REDIS_PORT = 16292
REDIS_PASSWORD = 'your-secret-password'
from gredisql.core import Server
server = Server(
REDIS_HOST=REDIS_HOST,
REDIS_PORT=REDIS_PORT,
REDIS_PASSWORD=REDIS_PASSWORD
)
server.run()
Now navigate to http://localhost:5055/graphql and voilà.
Metadata
Release files for gredisql 0.0.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gredisql-0.0.11.tar.gz | 6.6 kB | Without provenance | Details for gredisql-0.0.11.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gredisql-0.0.11-py3-none-any.whl | Python 3 | none | any | Details for gredisql-0.0.11-py3-none-any.whl |
Total release size: 12.9 kB
Release files / gredisql-0.0.11.tar.gz
| Download URL | gredisql-0.0.11.tar.gz |
|---|---|
| Size | 6.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3b288dadcaf25a96895f6f19f6a73bf1c05ee057322d69ec6a43c41352c6e5d5
|
|
BLAKE2b-256 checksum How to use checksums |
6f1eaff49f5fee361daf695b1c89f67558449ca7fbac5d14e5624fdd065a3bf0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.8.10
|
Release files / gredisql-0.0.11-py3-none-any.whl
| Download URL | gredisql-0.0.11-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
04f9aad50011783533c7920285750e27bca4edf3f8f6907106058ed32a5fba23
|
|
BLAKE2b-256 checksum How to use checksums |
e98dc32d65f098bf361ab00c0cf558593831e1b9fc385e87159950a1bc44a0ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.8.10
|
Security for gredisql 0.0.11
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.