3

Is it possible to simultaneously access single SQLite database at server from multiple clients applications of Flex(web and AIR applications)?

Is there any locking of database?

What i am trying todo is, i want to store my data in SQLite database at server side and i want that Flex applications both in web and AIR can simultaneously fetch data from the same database at server.

Is this possible to achieve with SQLite and Flex applications?

Is there any Better way to achieve this in Flex?

J_A_X
  • 12,857
  • 1
  • 25
  • 31
Gannesh
  • 183
  • 12
  • Don't use SQLite if you want concurrent connections to the middleware to give data. SQLite is a simplistic implementation and you should go with something a bit more robust. – J_A_X Aug 19 '11 at 08:44

1 Answers1

2

I've recently been doing quite a bit of wrestling with SQLite and concurrency. It's sort of a bitch, but it IS doable.

The issue is, when you issue writes to a SQLite database you lock the entire thing (in comparison to row locking, which other solutions support). If you're issuing tons of writes from multiple locations/threads, you're going to wind up hitting walls when 'database locked' errors show up.

I think it's possible to increase the timeout on SQLite queries so these issues become... slightly smaller issues. They are still issues nonetheless.

Another issue you may run into with SQLite is using FOR UPDATE. This is used when you need to retrieve some rows, compute things given the data, then issue an update without other queries reading those rows in the meantime. It does not support such a construct. You can get around it, but you have to explicitly lock the entire database while you do this update (you'll see someone addressing this here).

Concurrent reads are fine, so maybe it will work for you.

I suppose the TL;DR of this whole thing is that it depends on how many concurrent hits you expect to be having on the database. If you expect a lot, perhaps you should look into a more robust database solution like postgresql.

I'm not a database expert by any means, but I hope that points you in the right direction.

Reno
  • 232
  • 1
  • 8
  • Ok, thanks for the Help. Can we use SQLite for flex web applications? – Gannesh Aug 19 '11 at 06:12
  • [This](http://stackoverflow.com/questions/1154951/sqlite-and-flex) may be a relevant place to look. I don't know much about Flex, just SQLite and concurrency. Edit: Just came across [this](http://stackoverflow.com/questions/4195554/can-a-flex-web-app-access-a-sqlite-database) as well. Perhaps not? – Reno Aug 19 '11 at 07:25
  • 3
    @Gannesh No you can't. SQLite is only available with AIR. Unless you use a server-side language to access SQLite on the server of course. – RIAstar Aug 19 '11 at 07:47