Coder Social home page Coder Social logo

Comments (17)

otoolep avatar otoolep commented on May 12, 2024

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.

otoolep avatar otoolep commented on May 12, 2024

What do you see if you issue the query today? I have not tested it.

from rqlite.

zmedico avatar zmedico commented on May 12, 2024

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.

otoolep avatar otoolep commented on May 12, 2024

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.

otoolep avatar otoolep commented on May 12, 2024

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.

zmedico avatar zmedico commented on May 12, 2024

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.

otoolep avatar otoolep commented on May 12, 2024

This should now be fully supported on master. Please take a look @zmedico and let me know what you think.

from rqlite.

zmedico avatar zmedico commented on May 12, 2024

It works great, thank you!

from rqlite.

otoolep avatar otoolep commented on May 12, 2024

@zmedico -- are you planning to make your Python driver generally available? If so, I'd be interested in seeing it.

from rqlite.

otoolep avatar otoolep commented on May 12, 2024

I guess by "release soon" you do mean to make it available to general use.

from rqlite.

zmedico avatar zmedico commented on May 12, 2024

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.

zmedico avatar zmedico commented on May 12, 2024

I also made an sqlalchemy dialect that I used to test pyrqlite:

https://github.com/zmedico/sqlalchemy-rqlite

from rqlite.

otoolep avatar otoolep commented on May 12, 2024

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.

zmedico avatar zmedico commented on May 12, 2024

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.

otoolep avatar otoolep commented on May 12, 2024

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.

zmedico avatar zmedico commented on May 12, 2024

As for the API, I've made some final changes.

Looks good.

from rqlite.

zmedico avatar zmedico commented on May 12, 2024

Now pyrqlite uses the rqlite 2.0 API.

from rqlite.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.