codingdir logo sitemap sitemap |
Home
PHP
C#
C++
ANDROID
JAVA
JAVASCRIPT
PYTHON

Using Haskell's HDBC, can I use a single SQLite connection across multiple threads?


By : , Category : database

I searched through the hdbc-sqlite code and found this comment:

Logic for handling counts of changes: look at the total changes before and after the query. If they differ, then look at the local changes. (The local change counter appears to not be updated unless really running a query that makes a change, according to the docs.)

This is OK thread-wise because SQLite doesn't support using a given dbh in more than one thread anyway.

The official Sqlite documentation has a whole page about this topic

The FAQ says:

(5) Can multiple applications or multiple instances of the same application access a single database file at the same time?

Multiple processes can have the same database open at the same time. Multiple processes can be doing a SELECT at the same time. But only one process can be making changes to the database at any moment in time, however.

This information would exclude both of your approaches. Perhaps you can write some tests for this to show that this information are wrong.

ReLated :

Ok,

I see that HDBC may not be able to provide this ability, but I found this extension for SQLite:

https://github.com/eatnumber1/sqlite-regexp

which will do just that via an SQL LOAD statement. Of course, this adds an external dependency, but it fixas the problem (without having to rewrite lots and lots of code).

EDIT:

Actually, it seems that I cannot use load_extension(X) inside of HDBC, which means that I cannot loda the extension. So this is still an open issue.

No, it is not supported currently in hdbc.

Though i see no purpose for this kind of feature.

How would it be better than

let sql1 = "select 1,2,3 union all select 2,3,4"
    sql2 = " select 'a', 'b'"

c <- connectODBC connectionString

rs1 <- quickQuery c sql1 []
rs2 <- quickQuery c sql2 []

return (rs1,rs2)

or if you really insist on having dirrerent records with different number of fileds and types of fields in one list (hmm weird but ok) you could do this:

return $ rs1 ++ rs2

See the Netty wikis for a good general description of the threading model. In summary Netty 4.0+ will not introduce concurrency into the channel handling operations. Check out the majority of the netty examples and you will notice the lack of synchronization because of this. Operating on channels concurrently would introduce more complexity to the framework and interface to interact with the framework.

I think the question is does your use case support being split amongst multiple channels? It depends upon a lot of factors but if you algorithms and data support parallelization then you may see improvements in overall throughput.

Netty does provide a ChannelGroup but I'm not sure if this fits in with your usecase.

You can have only one transaction per connection.

There is no mechanism with which you could get multiple write transactions at the same time.

Comments


Message :
Login to Add Your Comments .
How to disable registered OpenCL platforms on Windows?
Is Observable broken in Angular 2 Beta 3?
Cross-thread operation not valid when using Invoke
How to pass an IEnumerable or queryable list of properties from Controller to View
Finding numbers after a certain keyword using Python
Pocketsphinx recognizes random phrases in a silence
Passing non-thread-safe objects through thread-safe containers
React scroll nav
BizTalk WCF-BasicHttp Adapter does not allow Empty string for Service Certificate Props
Why property ''cause" of Exception is repeating forever?
Privacy Policy 2017 © codingdir.com All Rights Reserved .