RE: [sqlite] how to fix problem of lock

2006-04-04 Thread Marian Olteanu
How long does one INSERT take? Do you have long transactions with INSERTs?
If you have one INSERT at a time and it doesn't take too long, and still you
have reader starvation issues with the SELECTs, the only solution that I see
is to queue requests and make sure that they are served on a
first-come-first-served basis. 

-Original Message-
From: Cesar David Rodas Maldonado [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, April 04, 2006 1:23 PM
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] how to fix problem of lock

Please people help me :D, the project will be open source...

On 4/4/06, Cesar David Rodas Maldonado <[EMAIL PROTECTED]> wrote:
>
> OK English is not my first language, i am from south America, from
> Paraguay so i speak Spanish...
>
> I am doing a project in C multiplataform.. right it project like google,
> for a Linux.
>
> the project uses SQ Lite for repository.
>
> The software is a server which listen connection UDP. The server could
> index (INSERT) and search within the database (SELECT).
>
> The problem is when i do so much connection at the same time for do index
> and search at the same time.
>
> Know is it clear? sorry for my english :D
>
> Thanxs
>
>
>
>
> On 4/3/06, John Stanton <[EMAIL PROTECTED]> wrote:
> >
> > Try to explain what you are doing.  How do you access SQLITE?  What
> > language?  What SQL are you using.  How many concurrent users do you
> > have?  Are you getting a LOCK error because of multiple users?
> >
> > Cesar David Rodas Maldonado wrote:
> > > please i need some help
> > > On 4/3/06, Cesar David Rodas Maldonado <[EMAIL PROTECTED]> wrote:
> > >
> > >>i insert numbers and  select numbers, so what could be the solutions,
> > >>couse i have to do that
> > >>
> > >>
> > >>On 4/3/06, Pam Greene < [EMAIL PROTECTED] > wrote:
> > >>
> > >>>An INSERT can change the results of your SELECT, so the database has
> > to
> > >>>be
> > >>>locked during INSERT.  Otherwise, the result of your SELECT would
> > depend
> > >>>on
> > >>>whether the INSERT had finished yet.  (The INSERT might even have
> > only
> > >>>partly finished, which would mean the SELECT was looking at a
> > database
> > >>>in an
> > >>>inconsistent state.)  It's not good to have unpredictable results
> > like
> > >>>that.
> > >>>
> > >>>For more explanation of why what you want isn't a good idea, see any
> > >>>discussion of an "ACID" database, for example
> > >>>http://en.wikipedia.org/wiki/ACID .
> > >>>
> > >>>- Pam
> > >>>
> > >>>On 4/3/06, Cesar David Rodas Maldonado <[EMAIL PROTECTED]> wrote:
> > >>>
> > >>>>HElp me, couse i just need to do insert and select, i dont use
> > delete
> > >>>
> > >>>or
> > >>>
> > >>>>replate or update
> > >>>>
> > >>>>On 4/3/06, Cesar David Rodas Maldonado < [EMAIL PROTECTED] > wrote:
> > >>>>
> > >>>>>thanx man
> > >>>>>
> > >>>>>
> > >>>>>but is posible open several DATABASE with a programm and do
> > >>>
> > >>>transaccion
> > >>>
> > >>>>>without locked the table???
> > >>>>>
> > >>>>>On 4/3/06, Jay Sprenkle < [EMAIL PROTECTED]> wrote:
> > >>>>>
> > >>>>>
> > >>>>>>On 4/3/06, Cesar David Rodas Maldonado < [EMAIL PROTECTED] > wrote:
> > >>>>>>
> > >>>>>>>I have a database ok... i do a lot of insert and select, but
> > >>>
> > >>>>there
> > >>>>
> > >>>>>>is
> > >>>>>>
> > >>>>>>>sometime that i cant do the select couse the database is
> > >>>
> > >>>locked...
> > >>>
> > >>>>>>>i have to do a lot of insert every time, so how can i do for
> > >>>
> > >>>dont
> > >>>
> > >>>>lock
> > >>>>
> > >>>>>>the
> > >>>>>>
> > >>>>>>>database...
> > >>>>>>>
> > >>>>>>>understand guy?
> > >>>>>>
> > >>>>>>Try this:
> > >>>>>>http://sqlite.org/lang_transaction.html
> > >>>>>>
> > >>>>>
> > >>>>>
> > >>>>
> > >>>
> > >
> >
> >
>



Re: [sqlite] how to fix problem of lock

2006-04-04 Thread John Stanton
The method I have found works well and efficiently is to surround your 
Sqlite accesses with a semaphore and have accessing processes WAIT to 
get access to Sqlite.  For best performance you would only block when an 
INSERT was in progress and let multiple SELECTs run concurrently.


This assumes that all your users go through the same interface so that 
they can co-operate.


The alternative is to put busy logic into your Sqlite code, but that is 
tedious and cannot be as efficient as synchronising using the more 
efficient kernel based method of a semaphore.


Since it is a single file and linked into the application Sqlite is 
essentially single user, requiring that only one process at a time 
modify the database.  It has to use a file lock to enforce that 
constraint.  If you work with it in your design you can transparently 
handle large numbers of users.


As you will already have appreciated, a multi-user Sqlite system must 
have short transactions to effectively share access.  You might also 
look to making users who only read the database be read-only.


In an extreme case you could look to having database INSERTs be handled 
by a daemon which would single stream access.


Cesar David Rodas Maldonado wrote:

OK English is not my first language, i am from south America, from Paraguay
so i speak Spanish...

I am doing a project in C multiplataform.. right it project like google, for
a Linux.

the project uses SQ Lite for repository.

The software is a server which listen connection UDP. The server could index
(INSERT) and search within the database (SELECT).

The problem is when i do so much connection at the same time for do index
and search at the same time.

Know is it clear? sorry for my english :D

Thanxs



On 4/3/06, John Stanton <[EMAIL PROTECTED]> wrote:


Try to explain what you are doing.  How do you access SQLITE?  What
language?  What SQL are you using.  How many concurrent users do you
have?  Are you getting a LOCK error because of multiple users?

Cesar David Rodas Maldonado wrote:


please i need some help
On 4/3/06, Cesar David Rodas Maldonado <[EMAIL PROTECTED]> wrote:



i insert numbers and  select numbers, so what could be the solutions,
couse i have to do that


On 4/3/06, Pam Greene < [EMAIL PROTECTED]> wrote:



An INSERT can change the results of your SELECT, so the database has to



be
locked during INSERT.  Otherwise, the result of your SELECT would


depend


on
whether the INSERT had finished yet.  (The INSERT might even have only
partly finished, which would mean the SELECT was looking at a database
in an
inconsistent state.)  It's not good to have unpredictable results like
that.

For more explanation of why what you want isn't a good idea, see any
discussion of an "ACID" database, for example
http://en.wikipedia.org/wiki/ACID .

- Pam

On 4/3/06, Cesar David Rodas Maldonado <[EMAIL PROTECTED]> wrote:



HElp me, couse i just need to do insert and select, i dont use delete


or



replate or update

On 4/3/06, Cesar David Rodas Maldonado <[EMAIL PROTECTED] > wrote:



thanx man


but is posible open several DATABASE with a programm and do


transaccion



without locked the table???

On 4/3/06, Jay Sprenkle < [EMAIL PROTECTED]> wrote:




On 4/3/06, Cesar David Rodas Maldonado < [EMAIL PROTECTED]> wrote:



I have a database ok... i do a lot of insert and select, but



there



is



sometime that i cant do the select couse the database is


locked...



i have to do a lot of insert every time, so how can i do for


dont



lock



the



database...

understand guy?


Try this:
http://sqlite.org/lang_transaction.html












RE: [sqlite] how to fix problem of lock

2006-04-04 Thread Doug Nebeker
>From http://www.hwaci.com/sw/sqlite/whentouse.html
"Situations Where Another RDBMS May Work Better"
* High Concurrency

SQLite uses reader/writer locks on the entire database file. That means
if any process is reading from any part of the database, all other
processes are prevented from writing any other part of the database.
Similarly, if any one process is writing to the database, all other
processes are prevented from reading any other part of the database. For
many situations, this is not a problem. Each application does its
database work quickly and moves on, and no lock lasts for more than a
few dozen milliseconds. But there are some applications that require
more concurrency, and those applications may need to seek a different
solution. 

If you are really writing an app like Google, SQLite is quite possibly
not the best solution because of its locking.  


-Original Message-
From: Cesar David Rodas Maldonado [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, April 04, 2006 1:23 PM
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] how to fix problem of lock

Please people help me :D, the project will be open source...

On 4/4/06, Cesar David Rodas Maldonado <[EMAIL PROTECTED]> wrote:
>
> OK English is not my first language, i am from south America, from 
> Paraguay so i speak Spanish...
>
> I am doing a project in C multiplataform.. right it project like 
> google, for a Linux.
>
> the project uses SQ Lite for repository.
>
> The software is a server which listen connection UDP. The server could

> index (INSERT) and search within the database (SELECT).
>
> The problem is when i do so much connection at the same time for do 
> index and search at the same time.
>
> Know is it clear? sorry for my english :D
>
> Thanxs
>
>
>
>
> On 4/3/06, John Stanton <[EMAIL PROTECTED]> wrote:
> >
> > Try to explain what you are doing.  How do you access SQLITE?  What 
> > language?  What SQL are you using.  How many concurrent users do you

> > have?  Are you getting a LOCK error because of multiple users?
> >
> > Cesar David Rodas Maldonado wrote:
> > > please i need some help
> > > On 4/3/06, Cesar David Rodas Maldonado <[EMAIL PROTECTED]> wrote:
> > >
> > >>i insert numbers and  select numbers, so what could be the 
> > >>solutions, couse i have to do that
> > >>
> > >>
> > >>On 4/3/06, Pam Greene < [EMAIL PROTECTED] > wrote:
> > >>
> > >>>An INSERT can change the results of your SELECT, so the database 
> > >>>has
> > to
> > >>>be
> > >>>locked during INSERT.  Otherwise, the result of your SELECT would
> > depend
> > >>>on
> > >>>whether the INSERT had finished yet.  (The INSERT might even have
> > only
> > >>>partly finished, which would mean the SELECT was looking at a
> > database
> > >>>in an
> > >>>inconsistent state.)  It's not good to have unpredictable results
> > like
> > >>>that.
> > >>>
> > >>>For more explanation of why what you want isn't a good idea, see 
> > >>>any discussion of an "ACID" database, for example 
> > >>>http://en.wikipedia.org/wiki/ACID .
> > >>>
> > >>>- Pam
> > >>>
> > >>>On 4/3/06, Cesar David Rodas Maldonado <[EMAIL PROTECTED]> wrote:
> > >>>
> > >>>>HElp me, couse i just need to do insert and select, i dont use
> > delete
> > >>>
> > >>>or
> > >>>
> > >>>>replate or update
> > >>>>
> > >>>>On 4/3/06, Cesar David Rodas Maldonado < [EMAIL PROTECTED] >
wrote:
> > >>>>
> > >>>>>thanx man
> > >>>>>
> > >>>>>
> > >>>>>but is posible open several DATABASE with a programm and do
> > >>>
> > >>>transaccion
> > >>>
> > >>>>>without locked the table???
> > >>>>>
> > >>>>>On 4/3/06, Jay Sprenkle < [EMAIL PROTECTED]> wrote:
> > >>>>>
> > >>>>>
> > >>>>>>On 4/3/06, Cesar David Rodas Maldonado < [EMAIL PROTECTED] >
wrote:
> > >>>>>>
> > >>>>>>>I have a database ok... i do a lot of insert and select, 
> > >>>>>>>but
> > >>>
> > >>>>there
> > >>>>
> > >>>>>>is
> > >>>>>>
> > >>>>>>>sometime that i cant do the select couse the database is
> > >>>
> > >>>locked...
> > >>>
> > >>>>>>>i have to do a lot of insert every time, so how can i do for
> > >>>
> > >>>dont
> > >>>
> > >>>>lock
> > >>>>
> > >>>>>>the
> > >>>>>>
> > >>>>>>>database...
> > >>>>>>>
> > >>>>>>>understand guy?
> > >>>>>>
> > >>>>>>Try this:
> > >>>>>>http://sqlite.org/lang_transaction.html
> > >>>>>>
> > >>>>>
> > >>>>>
> > >>>>
> > >>>
> > >
> >
> >
>


To find out more about Reuters visit www.about.reuters.com

Any views expressed in this message are those of the individual sender, except 
where the sender specifically states them to be the views of Reuters Ltd.



Re: [sqlite] how to fix problem of lock

2006-04-04 Thread Cesar David Rodas Maldonado
Thanx fred

On 4/4/06, Fred Williams <[EMAIL PROTECTED]> wrote:
>
> I would suggest as a beginning:
>
> www.hwaci.com/sw/sqlite/whentouse.html
>
> www.hwaci.com/sw/sqlite/lockingv3.html
>
> www.hwaci.com/sw/sqlite/faq.html#q7
>
> www.hwaci.com/sw/sqlite/faq.html#q8
>
> www.sqlite.org/cvstrac/wiki?p=MultiThreading
>
> AND
>
> www.hwaci.com/sw/sqlite/
>
> has wealth of very helpful information about all things SQLite.
>
> Once you have digested all that information, perhaps you will be in a
> better position to ask more detailed and to the point questions.
> General cries for help pretty much go unnoticed here.
>
> Most everyone here does not have the time and especially the patience
> required to teach an SQLite beginner how to write a Google replacement.
>
> Fred
>
> > -Original Message-
> > From: Cesar David Rodas Maldonado [mailto:[EMAIL PROTECTED]
> > Sent: Tuesday, April 04, 2006 1:23 PM
> > To: sqlite-users@sqlite.org
> > Subject: Re: [sqlite] how to fix problem of lock
> >
> >
> > Please people help me :D, the project will be open source...
> >
> > On 4/4/06, Cesar David Rodas Maldonado <[EMAIL PROTECTED]> wrote:
> > >
> > > OK English is not my first language, i am from south America, from
> > > Paraguay so i speak Spanish...
> > >
> > > I am doing a project in C multiplataform.. right it project
> > like google,
> > > for a Linux.
> > >
> > > the project uses SQ Lite for repository.
> > >
> > > The software is a server which listen connection UDP. The
> > server could
> > > index (INSERT) and search within the database (SELECT).
> > >
> > > The problem is when i do so much connection at the same
> > time for do index
> > > and search at the same time.
> > >
> > > Know is it clear? sorry for my english :D
> > >
> > > Thanxs
> > >
> > >
> ...
>
>


RE: [sqlite] how to fix problem of lock

2006-04-04 Thread Fred Williams
I would suggest as a beginning:

www.hwaci.com/sw/sqlite/whentouse.html

www.hwaci.com/sw/sqlite/lockingv3.html

www.hwaci.com/sw/sqlite/faq.html#q7

www.hwaci.com/sw/sqlite/faq.html#q8

www.sqlite.org/cvstrac/wiki?p=MultiThreading

AND

www.hwaci.com/sw/sqlite/

has wealth of very helpful information about all things SQLite.

Once you have digested all that information, perhaps you will be in a
better position to ask more detailed and to the point questions.
General cries for help pretty much go unnoticed here.

Most everyone here does not have the time and especially the patience
required to teach an SQLite beginner how to write a Google replacement.

Fred

> -Original Message-
> From: Cesar David Rodas Maldonado [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, April 04, 2006 1:23 PM
> To: sqlite-users@sqlite.org
> Subject: Re: [sqlite] how to fix problem of lock
>
>
> Please people help me :D, the project will be open source...
>
> On 4/4/06, Cesar David Rodas Maldonado <[EMAIL PROTECTED]> wrote:
> >
> > OK English is not my first language, i am from south America, from
> > Paraguay so i speak Spanish...
> >
> > I am doing a project in C multiplataform.. right it project
> like google,
> > for a Linux.
> >
> > the project uses SQ Lite for repository.
> >
> > The software is a server which listen connection UDP. The
> server could
> > index (INSERT) and search within the database (SELECT).
> >
> > The problem is when i do so much connection at the same
> time for do index
> > and search at the same time.
> >
> > Know is it clear? sorry for my english :D
> >
> > Thanxs
> >
> >
...



Re: [sqlite] how to fix problem of lock

2006-04-04 Thread Cesar David Rodas Maldonado
Please people help me :D, the project will be open source...

On 4/4/06, Cesar David Rodas Maldonado <[EMAIL PROTECTED]> wrote:
>
> OK English is not my first language, i am from south America, from
> Paraguay so i speak Spanish...
>
> I am doing a project in C multiplataform.. right it project like google,
> for a Linux.
>
> the project uses SQ Lite for repository.
>
> The software is a server which listen connection UDP. The server could
> index (INSERT) and search within the database (SELECT).
>
> The problem is when i do so much connection at the same time for do index
> and search at the same time.
>
> Know is it clear? sorry for my english :D
>
> Thanxs
>
>
>
>
> On 4/3/06, John Stanton <[EMAIL PROTECTED]> wrote:
> >
> > Try to explain what you are doing.  How do you access SQLITE?  What
> > language?  What SQL are you using.  How many concurrent users do you
> > have?  Are you getting a LOCK error because of multiple users?
> >
> > Cesar David Rodas Maldonado wrote:
> > > please i need some help
> > > On 4/3/06, Cesar David Rodas Maldonado <[EMAIL PROTECTED]> wrote:
> > >
> > >>i insert numbers and  select numbers, so what could be the solutions,
> > >>couse i have to do that
> > >>
> > >>
> > >>On 4/3/06, Pam Greene < [EMAIL PROTECTED] > wrote:
> > >>
> > >>>An INSERT can change the results of your SELECT, so the database has
> > to
> > >>>be
> > >>>locked during INSERT.  Otherwise, the result of your SELECT would
> > depend
> > >>>on
> > >>>whether the INSERT had finished yet.  (The INSERT might even have
> > only
> > >>>partly finished, which would mean the SELECT was looking at a
> > database
> > >>>in an
> > >>>inconsistent state.)  It's not good to have unpredictable results
> > like
> > >>>that.
> > >>>
> > >>>For more explanation of why what you want isn't a good idea, see any
> > >>>discussion of an "ACID" database, for example
> > >>>http://en.wikipedia.org/wiki/ACID .
> > >>>
> > >>>- Pam
> > >>>
> > >>>On 4/3/06, Cesar David Rodas Maldonado <[EMAIL PROTECTED]> wrote:
> > >>>
> > HElp me, couse i just need to do insert and select, i dont use
> > delete
> > >>>
> > >>>or
> > >>>
> > replate or update
> > 
> > On 4/3/06, Cesar David Rodas Maldonado < [EMAIL PROTECTED] > wrote:
> > 
> > >thanx man
> > >
> > >
> > >but is posible open several DATABASE with a programm and do
> > >>>
> > >>>transaccion
> > >>>
> > >without locked the table???
> > >
> > >On 4/3/06, Jay Sprenkle < [EMAIL PROTECTED]> wrote:
> > >
> > >
> > >>On 4/3/06, Cesar David Rodas Maldonado < [EMAIL PROTECTED] > wrote:
> > >>
> > >>>I have a database ok... i do a lot of insert and select, but
> > >>>
> > there
> > 
> > >>is
> > >>
> > >>>sometime that i cant do the select couse the database is
> > >>>
> > >>>locked...
> > >>>
> > >>>i have to do a lot of insert every time, so how can i do for
> > >>>
> > >>>dont
> > >>>
> > lock
> > 
> > >>the
> > >>
> > >>>database...
> > >>>
> > >>>understand guy?
> > >>
> > >>Try this:
> > >>http://sqlite.org/lang_transaction.html
> > >>
> > >
> > >
> > 
> > >>>
> > >
> >
> >
>


Re: [sqlite] how to fix problem of lock

2006-04-04 Thread Cesar David Rodas Maldonado
OK English is not my first language, i am from south America, from Paraguay
so i speak Spanish...

I am doing a project in C multiplataform.. right it project like google, for
a Linux.

the project uses SQ Lite for repository.

The software is a server which listen connection UDP. The server could index
(INSERT) and search within the database (SELECT).

The problem is when i do so much connection at the same time for do index
and search at the same time.

Know is it clear? sorry for my english :D

Thanxs



On 4/3/06, John Stanton <[EMAIL PROTECTED]> wrote:
>
> Try to explain what you are doing.  How do you access SQLITE?  What
> language?  What SQL are you using.  How many concurrent users do you
> have?  Are you getting a LOCK error because of multiple users?
>
> Cesar David Rodas Maldonado wrote:
> > please i need some help
> > On 4/3/06, Cesar David Rodas Maldonado <[EMAIL PROTECTED]> wrote:
> >
> >>i insert numbers and  select numbers, so what could be the solutions,
> >>couse i have to do that
> >>
> >>
> >>On 4/3/06, Pam Greene < [EMAIL PROTECTED]> wrote:
> >>
> >>>An INSERT can change the results of your SELECT, so the database has to
>
> >>>be
> >>>locked during INSERT.  Otherwise, the result of your SELECT would
> depend
> >>>on
> >>>whether the INSERT had finished yet.  (The INSERT might even have only
> >>>partly finished, which would mean the SELECT was looking at a database
> >>>in an
> >>>inconsistent state.)  It's not good to have unpredictable results like
> >>>that.
> >>>
> >>>For more explanation of why what you want isn't a good idea, see any
> >>>discussion of an "ACID" database, for example
> >>>http://en.wikipedia.org/wiki/ACID .
> >>>
> >>>- Pam
> >>>
> >>>On 4/3/06, Cesar David Rodas Maldonado <[EMAIL PROTECTED]> wrote:
> >>>
> HElp me, couse i just need to do insert and select, i dont use delete
> >>>
> >>>or
> >>>
> replate or update
> 
> On 4/3/06, Cesar David Rodas Maldonado <[EMAIL PROTECTED] > wrote:
> 
> >thanx man
> >
> >
> >but is posible open several DATABASE with a programm and do
> >>>
> >>>transaccion
> >>>
> >without locked the table???
> >
> >On 4/3/06, Jay Sprenkle < [EMAIL PROTECTED]> wrote:
> >
> >
> >>On 4/3/06, Cesar David Rodas Maldonado < [EMAIL PROTECTED]> wrote:
> >>
> >>>I have a database ok... i do a lot of insert and select, but
> >>>
> there
> 
> >>is
> >>
> >>>sometime that i cant do the select couse the database is
> >>>
> >>>locked...
> >>>
> >>>i have to do a lot of insert every time, so how can i do for
> >>>
> >>>dont
> >>>
> lock
> 
> >>the
> >>
> >>>database...
> >>>
> >>>understand guy?
> >>
> >>Try this:
> >>http://sqlite.org/lang_transaction.html
> >>
> >
> >
> 
> >>>
> >
>
>


Re: [sqlite] how to fix problem of lock

2006-04-03 Thread John Stanton
Try to explain what you are doing.  How do you access SQLITE?  What 
language?  What SQL are you using.  How many concurrent users do you 
have?  Are you getting a LOCK error because of multiple users?


Cesar David Rodas Maldonado wrote:

please i need some help
On 4/3/06, Cesar David Rodas Maldonado <[EMAIL PROTECTED]> wrote:


i insert numbers and  select numbers, so what could be the solutions,
couse i have to do that


On 4/3/06, Pam Greene < [EMAIL PROTECTED]> wrote:


An INSERT can change the results of your SELECT, so the database has to
be
locked during INSERT.  Otherwise, the result of your SELECT would depend
on
whether the INSERT had finished yet.  (The INSERT might even have only
partly finished, which would mean the SELECT was looking at a database
in an
inconsistent state.)  It's not good to have unpredictable results like
that.

For more explanation of why what you want isn't a good idea, see any
discussion of an "ACID" database, for example
http://en.wikipedia.org/wiki/ACID .

- Pam

On 4/3/06, Cesar David Rodas Maldonado <[EMAIL PROTECTED]> wrote:


HElp me, couse i just need to do insert and select, i dont use delete


or


replate or update

On 4/3/06, Cesar David Rodas Maldonado <[EMAIL PROTECTED]> wrote:


thanx man


but is posible open several DATABASE with a programm and do


transaccion


without locked the table???

On 4/3/06, Jay Sprenkle < [EMAIL PROTECTED]> wrote:



On 4/3/06, Cesar David Rodas Maldonado < [EMAIL PROTECTED]> wrote:


I have a database ok... i do a lot of insert and select, but



there


is


sometime that i cant do the select couse the database is


locked...


i have to do a lot of insert every time, so how can i do for


dont


lock


the


database...

understand guy?


Try this:
http://sqlite.org/lang_transaction.html














Re: [sqlite] how to fix problem of lock

2006-04-03 Thread Pam Greene
You can't SELECT from your database while an INSERT has not finished.
SQLite will return the SQLITE_BUSY error if you try.  You can't fix that.
It is not broken.  In fact, it's necessary.

You can have your application simply loop with a delay, trying the SELECT
and waiting for the SQLITE_BUSY to go away, if you want.  Or you can use
sqlite3_busy_timeout() to insert a delay between your SELECT and the
SQLITE_BUSY response.  Or you can use sqlite3_busy_handler() to set a
callback function that SQLite will (usually) call instead of returning
SQLITE_BUSY.

You could also make a copy of your database before you start the INSERTs.
INSERT into the copy and SELECT from the original.  When the INSERTs are
done, copy the copy back to the original.  That idea has its own problems:
be careful not to change the original while a SELECT is running, or to start
a new SELECT while the copy is running.  If you try this, you are disabling
some of the robustness of SQLite, and you will have to replace its
safeguards with your own.

- Pam

On 4/3/06, Cesar David Rodas Maldonado <[EMAIL PROTECTED]> wrote:
>
> please i need some help
> On 4/3/06, Cesar David Rodas Maldonado <[EMAIL PROTECTED]> wrote:
> >
> > i insert numbers and  select numbers, so what could be the solutions,
> > couse i have to do that
> >
> >
> > On 4/3/06, Pam Greene < [EMAIL PROTECTED]> wrote:
> > >
> > > An INSERT can change the results of your SELECT, so the database has
> to
> > > be
> > > locked during INSERT.  Otherwise, the result of your SELECT would
> depend
> > > on
> > > whether the INSERT had finished yet.  (The INSERT might even have only
> > > partly finished, which would mean the SELECT was looking at a database
> > > in an
> > > inconsistent state.)  It's not good to have unpredictable results like
> > > that.
> > >
> > > For more explanation of why what you want isn't a good idea, see any
> > > discussion of an "ACID" database, for example
> > > http://en.wikipedia.org/wiki/ACID .
> > >
> > > - Pam
> > >
> > > On 4/3/06, Cesar David Rodas Maldonado <[EMAIL PROTECTED]> wrote:
> > > >
> > > > HElp me, couse i just need to do insert and select, i dont use
> delete
> > > or
> > > > replate or update
> > > >
> > > > On 4/3/06, Cesar David Rodas Maldonado <[EMAIL PROTECTED]> wrote:
> > > > >
> > > > > thanx man
> > > > >
> > > > >
> > > > > but is posible open several DATABASE with a programm and do
> > > transaccion
> > > > > without locked the table???
> > > > >
> > > > > On 4/3/06, Jay Sprenkle < [EMAIL PROTECTED]> wrote:
> > > > >
> > > > > > On 4/3/06, Cesar David Rodas Maldonado < [EMAIL PROTECTED]>
> wrote:
> > > > > > > I have a database ok... i do a lot of insert and select,
> but
> > >
> > > > there
> > > > > > is
> > > > > > > sometime that i cant do the select couse the database is
> > > locked...
> > > > > > >
> > > > > > > i have to do a lot of insert every time, so how can i do for
> > > dont
> > > > lock
> > > > > > the
> > > > > > > database...
> > > > > > >
> > > > > > > understand guy?
> > > > > >
> > > > > > Try this:
> > > > > > http://sqlite.org/lang_transaction.html
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
>
>


Re: [sqlite] how to fix problem of lock

2006-04-03 Thread Jay Sprenkle
> I suspect that the tone of your messages and your insistence on getting
> some sort of unspecified help has irked more than a few members of this
> list.

I didn't think I could help without spanish.
I'm the guy who asked 'who is the bathroom' when I tried it last... ;)


Re: [sqlite] how to fix problem of lock

2006-04-03 Thread Kurt Welgehausen
"Cesar David Rodas Maldonado" <[EMAIL PROTECTED]> wrote:
> but is posible open several DATABASE with a programm and do transaccion
> without locked the table???

No.  A transaction will always lock the database at some
point.

Regards


Re: [sqlite] how to fix problem of lock

2006-04-03 Thread Dennis Cote

Cesar David Rodas Maldonado wrote:


please i need some help


Cesar,

I suspect that the tone of your messages and your insistence on getting 
some sort of unspecified help has irked more than a few members of this 
list.


I appreciate that English may not be your first language, but your 
statement of the problem is not clear. And until there is a clearer 
statement of the problem, I suspect you won't get any more help.


How are you accessing the database (i.e.are you using a wrapper)? Are 
you using separate processes or threads to do the writes (i.e. inserts) 
and reads (i.e. selects)? How often are you writing? How many records 
are your writing at once (i.e. are your updates batched)? How often are 
you reading? Which have higher priority, the reads or the writes?


As others have already tried to point out, SQLite does not allow another 
process to read a database while one is writing it. It simply can't be 
done. So one or the other will have to be delayed until the other is 
completed (i.e. the accesses must be serialized). There are several ways 
to do this depending upon on what, exactly, you are trying to do. You 
can use an external mutual exclusion mechanism, you can use transactions 
with retry loops, you can use a busy handler, etc.


SQLite can write data into a database and later read that data back out. 
It can do it with lots of data, and it can do it quickly. But sometimes 
there is more to it than just issuing insert and select statements.


Please lets us know more precisely what you are trying to do and what 
isn't working. Then I'm sure someone will be able to help you. If you 
won't invest some time to try to get the problem resolved, no one else 
will either.


Dennis Cote

P.S. "couse" is not an English word. I think you should try "because" 
instead.







Re: [sqlite] how to fix problem of lock

2006-04-03 Thread Cesar David Rodas Maldonado
please i need some help
On 4/3/06, Cesar David Rodas Maldonado <[EMAIL PROTECTED]> wrote:
>
> i insert numbers and  select numbers, so what could be the solutions,
> couse i have to do that
>
>
> On 4/3/06, Pam Greene < [EMAIL PROTECTED]> wrote:
> >
> > An INSERT can change the results of your SELECT, so the database has to
> > be
> > locked during INSERT.  Otherwise, the result of your SELECT would depend
> > on
> > whether the INSERT had finished yet.  (The INSERT might even have only
> > partly finished, which would mean the SELECT was looking at a database
> > in an
> > inconsistent state.)  It's not good to have unpredictable results like
> > that.
> >
> > For more explanation of why what you want isn't a good idea, see any
> > discussion of an "ACID" database, for example
> > http://en.wikipedia.org/wiki/ACID .
> >
> > - Pam
> >
> > On 4/3/06, Cesar David Rodas Maldonado <[EMAIL PROTECTED]> wrote:
> > >
> > > HElp me, couse i just need to do insert and select, i dont use delete
> > or
> > > replate or update
> > >
> > > On 4/3/06, Cesar David Rodas Maldonado <[EMAIL PROTECTED]> wrote:
> > > >
> > > > thanx man
> > > >
> > > >
> > > > but is posible open several DATABASE with a programm and do
> > transaccion
> > > > without locked the table???
> > > >
> > > > On 4/3/06, Jay Sprenkle < [EMAIL PROTECTED]> wrote:
> > > >
> > > > > On 4/3/06, Cesar David Rodas Maldonado < [EMAIL PROTECTED]> wrote:
> > > > > > I have a database ok... i do a lot of insert and select, but
> >
> > > there
> > > > > is
> > > > > > sometime that i cant do the select couse the database is
> > locked...
> > > > > >
> > > > > > i have to do a lot of insert every time, so how can i do for
> > dont
> > > lock
> > > > > the
> > > > > > database...
> > > > > >
> > > > > > understand guy?
> > > > >
> > > > > Try this:
> > > > > http://sqlite.org/lang_transaction.html
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>


Re: [sqlite] how to fix problem of lock

2006-04-03 Thread Cesar David Rodas Maldonado
i insert numbers and  select numbers, so what could be the solutions, couse
i have to do that

On 4/3/06, Pam Greene <[EMAIL PROTECTED]> wrote:
>
> An INSERT can change the results of your SELECT, so the database has to be
> locked during INSERT.  Otherwise, the result of your SELECT would depend
> on
> whether the INSERT had finished yet.  (The INSERT might even have only
> partly finished, which would mean the SELECT was looking at a database in
> an
> inconsistent state.)  It's not good to have unpredictable results like
> that.
>
> For more explanation of why what you want isn't a good idea, see any
> discussion of an "ACID" database, for example
> http://en.wikipedia.org/wiki/ACID .
>
> - Pam
>
> On 4/3/06, Cesar David Rodas Maldonado <[EMAIL PROTECTED]> wrote:
> >
> > HElp me, couse i just need to do insert and select, i dont use delete or
> > replate or update
> >
> > On 4/3/06, Cesar David Rodas Maldonado <[EMAIL PROTECTED]> wrote:
> > >
> > > thanx man
> > >
> > >
> > > but is posible open several DATABASE with a programm and do
> transaccion
> > > without locked the table???
> > >
> > > On 4/3/06, Jay Sprenkle < [EMAIL PROTECTED]> wrote:
> > >
> > > > On 4/3/06, Cesar David Rodas Maldonado < [EMAIL PROTECTED]> wrote:
> > > > > I have a database ok... i do a lot of insert and select, but
> > there
> > > > is
> > > > > sometime that i cant do the select couse the database is locked...
> > > > >
> > > > > i have to do a lot of insert every time, so how can i do for dont
> > lock
> > > > the
> > > > > database...
> > > > >
> > > > > understand guy?
> > > >
> > > > Try this:
> > > > http://sqlite.org/lang_transaction.html
> > > >
> > >
> > >
> >
> >
>
>


Re: [sqlite] how to fix problem of lock

2006-04-03 Thread Pam Greene
An INSERT can change the results of your SELECT, so the database has to be
locked during INSERT.  Otherwise, the result of your SELECT would depend on
whether the INSERT had finished yet.  (The INSERT might even have only
partly finished, which would mean the SELECT was looking at a database in an
inconsistent state.)  It's not good to have unpredictable results like
that.

For more explanation of why what you want isn't a good idea, see any
discussion of an "ACID" database, for example
http://en.wikipedia.org/wiki/ACID .

- Pam

On 4/3/06, Cesar David Rodas Maldonado <[EMAIL PROTECTED]> wrote:
>
> HElp me, couse i just need to do insert and select, i dont use delete or
> replate or update
>
> On 4/3/06, Cesar David Rodas Maldonado <[EMAIL PROTECTED]> wrote:
> >
> > thanx man
> >
> >
> > but is posible open several DATABASE with a programm and do transaccion
> > without locked the table???
> >
> > On 4/3/06, Jay Sprenkle < [EMAIL PROTECTED]> wrote:
> >
> > > On 4/3/06, Cesar David Rodas Maldonado < [EMAIL PROTECTED]> wrote:
> > > > I have a database ok... i do a lot of insert and select, but
> there
> > > is
> > > > sometime that i cant do the select couse the database is locked...
> > > >
> > > > i have to do a lot of insert every time, so how can i do for dont
> lock
> > > the
> > > > database...
> > > >
> > > > understand guy?
> > >
> > > Try this:
> > > http://sqlite.org/lang_transaction.html
> > >
> >
> >
>
>


Re: [sqlite] how to fix problem of lock

2006-04-03 Thread Cesar David Rodas Maldonado
HElp me, couse i just need to do insert and select, i dont use delete or
replate or update

On 4/3/06, Cesar David Rodas Maldonado <[EMAIL PROTECTED]> wrote:
>
> thanx man
>
>
> but is posible open several DATABASE with a programm and do transaccion
> without locked the table???
>
> On 4/3/06, Jay Sprenkle < [EMAIL PROTECTED]> wrote:
>
> > On 4/3/06, Cesar David Rodas Maldonado < [EMAIL PROTECTED]> wrote:
> > > I have a database ok... i do a lot of insert and select, but there
> > is
> > > sometime that i cant do the select couse the database is locked...
> > >
> > > i have to do a lot of insert every time, so how can i do for dont lock
> > the
> > > database...
> > >
> > > understand guy?
> >
> > Try this:
> > http://sqlite.org/lang_transaction.html
> >
>
>


Re: [sqlite] how to fix problem of lock

2006-04-03 Thread Cesar David Rodas Maldonado
thanx man


but is posible open several DATABASE with a programm and do transaccion
without locked the table???

On 4/3/06, Jay Sprenkle <[EMAIL PROTECTED]> wrote:
>
> On 4/3/06, Cesar David Rodas Maldonado <[EMAIL PROTECTED]> wrote:
> > I have a database ok... i do a lot of insert and select, but there
> is
> > sometime that i cant do the select couse the database is locked...
> >
> > i have to do a lot of insert every time, so how can i do for dont lock
> the
> > database...
> >
> > understand guy?
>
> Try this:
> http://sqlite.org/lang_transaction.html
>


Re: [sqlite] how to fix problem of lock

2006-04-03 Thread Jay Sprenkle
On 4/3/06, Cesar David Rodas Maldonado <[EMAIL PROTECTED]> wrote:
> I have a database ok... i do a lot of insert and select, but there is
> sometime that i cant do the select couse the database is locked...
>
> i have to do a lot of insert every time, so how can i do for dont lock the
> database...
>
> understand guy?

Try this:
http://sqlite.org/lang_transaction.html


Re: [sqlite] how to fix problem of lock

2006-04-03 Thread Cesar David Rodas Maldonado
I have a database ok... i do a lot of insert and select, but there is
sometime that i cant do the select couse the database is locked...

i have to do a lot of insert every time, so how can i do for dont lock the
database...

understand guy?

On 4/3/06, Jay Sprenkle <[EMAIL PROTECTED]> wrote:
>
> On 4/3/06, Cesar David Rodas Maldonado <[EMAIL PROTECTED]> wrote:
> > I have a database that i do a lot of insert and select... really a lot
> >
> > but i have a problem with the lock database, couse when i do a lot of
> insert
> > i can do a select
> >
> > i know that that is normal, but how can i fix it?, using a memory for
> insert
> > or using another database like a mirror or how???
>
> Your message isn't very clear.
> Maybe you can read part 7 here:
> http://www.sqlite.org/faq.html
>
>
> ---
> SqliteImporter: Command line fixed and delimited text import.
> http://www.reddawn.net/~jsprenkl/Sqlite
>


Re: [sqlite] how to fix problem of lock

2006-04-03 Thread Jay Sprenkle
On 4/3/06, Cesar David Rodas Maldonado <[EMAIL PROTECTED]> wrote:
> I have a database that i do a lot of insert and select... really a lot
>
> but i have a problem with the lock database, couse when i do a lot of insert
> i can do a select
>
> i know that that is normal, but how can i fix it?, using a memory for insert
> or using another database like a mirror or how???

Your message isn't very clear.
Maybe you can read part 7 here:
http://www.sqlite.org/faq.html


---
SqliteImporter: Command line fixed and delimited text import.
http://www.reddawn.net/~jsprenkl/Sqlite


[sqlite] how to fix problem of lock

2006-04-03 Thread Cesar David Rodas Maldonado
I have a database that i do a lot of insert and select... really a lot

but i have a problem with the lock database, couse when i do a lot of insert
i can do a select

i know that that is normal, but how can i fix it?, using a memory for insert
or using another database like a mirror or how???

thankx