You are not logged in.
Pages: 1
Hi Arnaud,
I might need to use Python to developer some clients that talk to a restful server powered by Synopse sqlite, since the client need to access some data that's easier to access by Python.
In short, the Python clients to use a thread to read data from other data sources and then write data to the sqlite database. To simplify things I plan to directly write the data to the sqlite database, instead of posting JSON data to the restful server (what do you think?), but the clients still need to send some some logs to the restful server to indicate the operation process.
I'm wondering if you can give me some hints as to what method to use for the communication between the server (developed in Delphi) and the clients (developed in Python). All the server and programs will be running on the same machine.
Thanks!
Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.
Offline
First of all, you are right: python clients must be on the same computer as the Synopse server. If not, direct access won't work over the network - you may loose some data. You'll need a real client/server protocol. So you should connect to the RESTful server.
So direct access to the SQLite3 DB may work, but I see two possible issues:
1. you may loose some data synchronization due to the caching mechanism integrated to the framework.
2. you may not being able to open the sqlite3 DB at the same time - the framework was not developed with the idea of sharing its file content.
The point 1 could be handled via some notification mechanism.
But the point 2 is a bit more difficult to implement, because of performance issues, and the way the SQLite3 engine was compiled for our framework.
I'd definitively tend NOT to access the DB files directly, but rely on the Synopse server.
Using HTTP should be the better for easy implementation.
Performances could be less than named pipes, but you'll definitively work fast. The speed bottleneck won't be in the HTTP procotol or our Synopse server I think, but in python itself, and in the SQLite3 engine (in case of INSERTs).
Take a look at those libraries:
- http://docs.python.org/library/json.html for direct serialization of a python object from and to JSON content;
- http://docs.python.org/library/httplib.html or http://docs.python.org/release/3.1.3/li … lient.html to have a HTTP/1.1 client.
If you write any handy python classes for working with Synopse SQlite3 framework server, it could be great to post them on the forum!
Offline
Thanks for the helpful info, Arnaud!
I'll be pleased to post some helpful code here if I even go for this approach, at this moment I'm just doing some technical research for a planned program.
If the Python code will talk to the server via http/json, I'm still wondering how the server side code will look like, which method should I use/extend?
Thanks!
Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.
Offline
Just call the RESTful commands as described in the documentation: HTTP/1.1 with GET/POST/PUT/DELETE and so on...
You have also the URI of much commands (including BATCH mode which could be useful in your case) in the source code interface comments.
Offline
That's a little more code to write...
Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.
Offline
I'll let you know how it goes when the project it's started
Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.
Offline
Pages: 1