Git Product home page Git Product logo

Comments (3)

AdamSLevy avatar AdamSLevy commented on June 12, 2024 1

I'm becoming increasingly interested in implementing this feature and may start taking a crack at it in the next few weeks in my spare time.

from sqlite.

bvinc avatar bvinc commented on June 12, 2024

BTW, I personally think that not having a database/sql driver is a selling point. Sure, you can add it and make it optional, but here are the reasons why I hate it.

  • It implements connection pooling. By default, each sqlite query will go to a random connection in the pool, which may be in a different state.
  • You lose the ability to set a lot of PRAGMA at proper times in the connection. Or really, you can do them, but they'll work only sometimes depending on the state of the connection in the pool.
  • Since you lose your ability to create connections, you have to come up with your own connection string syntax to control sqlite.
  • You must use their transactions. If some poor fool accidentally uses "BEGIN" and "COMMIT" for transactions, they'll be going into different connections. You must use database/sql transactions, which causes you to lose the ability to do things like "BEGIN EXCLUSIVE".
  • It adds a whole new layer of locks and pools which hurt performance.
  • The mattn driver already exists

Check the last question on the mattn driver's FAQ:

https://github.com/mattn/go-sqlite3

If you start using their driver normally, you'll immediately start getting problems with locked databases. They suggest that you use their custom connection string to enable shared cache mode, and then reduce the connection pool to only 1 connection. That's the suggested way of using it apparently.

I honestly don't understand how anyone is using sqlite through database/sql.

from sqlite.

crawshaw avatar crawshaw commented on June 12, 2024

A database/sql driver certainly should live in a separate package (probably sqlite/driver). I'm not working on it right now because I wouldn't be using it day-to-day, so I wouldn't give it the workout it needs to be high quality.

I do believe connection pooling is possible with sqlite, though not in the default way database/sql does it. This package includes a shared-cache based pool object. You just have to check out a connection to use it. (Because of src-string based caching of prepared statements, it's even safe to assume all of your statements have been prepared across the the pool.)

One of the big problems with that other driver that I wanted to address was lack of support for https://www.sqlite.org/unlock_notify.html, which I believe is important for using the shared cache effectively.

from sqlite.

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.