cozodb / cozo

A transactional, relational-graph-vector database that uses Datalog for query. The hippocampus for AI!
https://cozodb.org
Mozilla Public License 2.0
3.44k stars 108 forks source link

Connect Swift CozoDB Client to standalone HTTP Server? #170

Closed Jonovono closed 1 year ago

Jonovono commented 1 year ago

Hi, I am wondering if this is possible?

Similar to how in python you can:

client = Client('http', options={'host': 'http://127.0.0.1:9070'})
zh217 commented 1 year ago

Currently the swift client is a thin wrapper around the C library for convenience. As such, it doesn't have any bells and whistles like the Python client. For HTTP access to a server, I think using a dedicated HTTP client and parse the JSON output manually wouldn't be too difficult.

Jonovono commented 1 year ago

Thanks @zh217, ya, I might just do that. Should be simple enough. While I have you, have you looked into running CozoDB with Swift on server side? Where should I start if I want to explore that? I'm using the https://vapor.codes project. Wondering if it would make sense to get Cozo running this way or just have it as a seperate standalone http DB.

zh217 commented 1 year ago

Unfortunately, no, and in fact I don't know the swift language very well. Nonetheless as Swift can call into C with no problem I don't think it would be too difficult to make it work. You can look at https://github.com/cozodb/cozo/blob/main/cozo-lib-c/cozo_c.h for the C API and https://github.com/cozodb/cozo/blob/main/scripts/build-release-linux.sh for hints about how to compile the library. Basically for compiling the C library you want

cargo build --release -p cozo_c -F compact -F storage-rocksdb