Comments (17)
Thanks, let me see what I can do. I am re-working some rqlite (though the API should remain the same, I plan to just rework the distributed consensus part).
from rqlite.
What do you see if you issue the query today? I have not tested it.
from rqlite.
What do you see if you issue the query today? I have not tested it.
The last_insert_rowid() function works fine as it is, for example:
$ curl -L -XPOST 'localhost:4001/db?pretty&explain&transaction' -d '
CREATE TABLE foo (id integer not null primary key, name text);
INSERT INTO foo(name) VALUES("fiona");
SELECT last_insert_rowid() as rowid;
'
{
"time": "1.254978ms",
"failures": []
}
Since the above doesn't return the row id, it has to be retrieved as a separate transaction:
$ curl -L -G 'localhost:4001/db?pretty&explain' --data-urlencode 'q=SELECT last_insert_rowid() as rowid'
{
"time": "282.159µs",
"failures": [],
"rows": [
{
"rowid": "1"
}
]
}
from rqlite.
OK, I believe I know why this is -- it's because rqlite isn't built to support statements that mutate the database and return results, in the same POST body.
I should be able to fix that, I've never been too happy about it, and know better now.
from rqlite.
Let me try to fix it as part of the work I am doing in this branch: https://github.com/otoolep/rqlite/tree/hrqlite
from rqlite.
It's also useful to return number of rows affected by an UPDATE
statement. This value can be queried using SELECT changes() as changes
. If have tested this function with rqlite, and it also works:
$ curl -L -G 'localhost:4001/db?pretty&explain' --data-urlencode 'q=
SELECT changes() as changes, last_insert_rowid() as last_insert_rowid'
{
"time": "225.588µs",
"failures": [],
"rows": [
{
"changes": "1",
"last_insert_rowid": "1"
}
]
}
I can use this to implement python's Cursor.rowcount attribute.
EDIT: Now I see https://github.com/otoolep/rqlite/issues/4.
from rqlite.
This should now be fully supported on master. Please take a look @zmedico and let me know what you think.
from rqlite.
It works great, thank you!
from rqlite.
@zmedico -- are you planning to make your Python driver generally available? If so, I'd be interested in seeing it.
from rqlite.
I guess by "release soon" you do mean to make it available to general use.
from rqlite.
Yeah, I'm releasing it with MIT license:
https://github.com/zmedico/pyrqlite
Lots of things can be simplified thanks to the rqlite-2.0 API.
from rqlite.
I also made an sqlalchemy dialect that I used to test pyrqlite:
https://github.com/zmedico/sqlalchemy-rqlite
from rqlite.
Nice.
Depending on your seriousness, we should agree to lock down the API pretty soon. I think it's close, but I'd be interested in any feedback.
from rqlite.
I'm pretty happy with the 2.0 API as it currently is, but I think that ideally the URI would include a version component so that multiple versions can be supported simultaneously. Each version doesn't have to be supported forever. I'm not particularly invested in the 1.0 API, so I don't really care if it's dropped now (though it shouldn't be terribly difficult to continue supporting it).
What are your thoughts on adding a version component to the URI?
from rqlite.
I'm going to resist versioning the API for now, since the 1.0 API was badly done, and should never have existed in that form (after spending a couple of years building databases I know better now, you see). I think versioning might be overkill for my goals for rqlite.
As for the API, I've made some final changes. Check out the https://github.com/otoolep/rqlite/blob/master/README.md for full details.
from rqlite.
As for the API, I've made some final changes.
Looks good.
from rqlite.
Now pyrqlite uses the rqlite 2.0 API.
from rqlite.
Related Issues (20)
- Leader continues trying to heartbeat removed node HOT 8
- Null pointer panic HOT 7
- Add "vtypes" field to API response to indicate actual value types
- Read-only node showing failed to open store: set log info: failed to get last command index HOT 4
- Can't create a empty database in rqlite shell HOT 3
- failed to install snapshot HOT 26
- Leader election times seem too long with max current term HOT 16
- Recovery process can result in old snapshot getting sent to node HOT 43
- Rust sqlx-rqlite HOT 1
- CLI support Home and End key
- Build and upload binaries automatically HOT 3
- Which version of Sqlite dialect is supported? HOT 4
- PRAGMA foreign_keys are turning them off even we turn them on. HOT 4
- connect rqlite over unix sockets HOT 2
- how to debug random "database disk image is malformed" error? HOT 10
- rqlited + DNS client 100% CPU usage after network disconnecting (windows) HOT 21
- CTRL-C should stop the process HOT 1
- [FeatureRequest] Make number of retries configurable for /nodes and potentially other relevant http calls HOT 7
- Build from source fails in Windows VM HOT 7
- Synchronisation bug related to http.Server.AllowedOrigin HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rqlite.