lock base

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

lock base

MONSTRUO Hugo González
I have a network of computers that share a SQLite file.
Two tables share sales information: current and historical.
When I record a new record I must put a code equal to the major + 1.
I need to put the database in exclusivity to avoid recording records with
the same code.

How I do this ?
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: lock base

Simon Slavin-3


On 30 Sep 2017, at 3:18am, MONSTRUO Hugo González <[hidden email]> wrote:

> I have a network of computers that share a SQLite file.
> Two tables share sales information: current and historical.
> When I record a new record I must put a code equal to the major + 1.
> I need to put the database in exclusivity to avoid recording records with
> the same code.

See FAQ number 1:

<https://sqlite.org/faq.html>

Don’t hesitate to get back to us if you have questions.

Simon.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: lock base

Keith Medcalf
In reply to this post by MONSTRUO Hugo González

Start a transaction with BEGIN IMMEDIATE
Execute the selects necessary to compute "major"
Execute the "insert"
COMMIT the transaction

Write operations are always exclusive.  You merely need to start the "I need to write something" transaction before you read the database so that no one else can get in and make changes while you are working.

Or do you mean that the "network" is broken and that locking does not work properly, which is a common occurrence with most network file systems?  It is also why using SQLite (or any multiuser accessed/updated file) over a Network Filesystem is ill-advised.

Also, are you using the term "tables" loosely to mean two databases?  Or are you actually referring to two tables in the same database?
 
---
The fact that there's a Highway to Hell but only a Stairway to Heaven says a lot about anticipated traffic volume.

>-----Original Message-----
>From: sqlite-users [mailto:sqlite-users-
>[hidden email]] On Behalf Of MONSTRUO Hugo González
>Sent: Friday, 29 September, 2017 20:19
>To: [hidden email]
>Subject: [sqlite] lock base
>
>I have a network of computers that share a SQLite file.
>Two tables share sales information: current and historical.
>When I record a new record I must put a code equal to the major + 1.
>I need to put the database in exclusivity to avoid recording records
>with
>the same code.
>
>How I do this ?
>_______________________________________________
>sqlite-users mailing list
>[hidden email]
>http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users



_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: lock base

Simon Slavin-3
In reply to this post by Simon Slavin-3


On 30 Sep 2017, at 3:43am, Simon Slavin <[hidden email]> wrote:

> See FAQ number 1:

I’m sorry.  I misunderstood the question.  Please ignore that post.

Simon.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: lock base

Simon Slavin-3
In reply to this post by MONSTRUO Hugo González


On 30 Sep 2017, at 3:18am, MONSTRUO Hugo González <[hidden email]> wrote:

> When I record a new record I must put a code equal to the major + 1.

Why ?

Can’t you have one table use numbers from 1000000 upwards and the other use numbers from 2000000 upwards ?

Simon.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users