Re: [sqlite] 500 sqlites on one server machine?

2008-09-08 Thread Daniel van Ham Colchete
ye,

at the fifth question of the SQLite FAQ, at 
http://www.sqlite.org/faq.html, it is explained why using a sqlite file 
by multiple nodes over a network with a NFS filesystem is not a good 
idea. I would avoid it although the FAQ does not say 'it does not work', 
it only says 'it might not work'.

You might want to take a look at GlusterFS (www.glusterfs.org), it's a 
clustered filesystem that works well with fcntl() (the locking system). 
If you need a smaller latency, it will also work with infiniband.

Best regards,
Daniel Colchete

ye wrote:
> Hi, Igor:
> Thanks for reply!
> Yes, I just noticed the sqlite data file is nothing but a empty file.
> Thanks!
> About the remote visit, if the sqlite data file is created on a NFS, will
> the remote visiting process be considered as a equal local process?
>
> regards
> ye
>
>   


___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Ignoring "The"

2008-07-23 Thread Daniel van Ham Colchete
Andrew Gatt wrote:
> I have a table of music artist names which i'd like to output in order. 
> Normally i just use:
>
> select * from artists order by artist_name;
>
> What i'd really like to do is order the artists by name but ignore any 
> "the" or "the," preceding it.
>
> Any ideas?
>
> Thanks
>
> Andrew
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
>
>   
Store it like "Beatles, The" them make the transformation latter, if 
necessary?

That's one idea.

Best,
Daniel

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] UTF8

2006-07-27 Thread Daniel van Ham Colchete
Cesar David Rodas Maldonado wrote:
> I wanted to ask how can i know if a given text is UTF8 or ISO-8859-1?
Well, there might be a way if you only want to know if the text is UTF-8
or ISO-8859-1 (it means that you already know that is one is the other).

There are some invalid UTF-8 sequences. If you have something like 0xE5
0x61, that in ISO-8859-1 means 'a' = 'áa', you have an invalid
UTF-8 sequence and then you know that it is not an UTF-8 charset.

How do you test it? If you're using Linux you can try to convert your
string from UTF-8 to UTF-16 using glibc's iconv. If it is an ISO-8859-1
text and you are lucky enough to be an invalid UTF-8 (most likely) then
you have it!

If you are not using Linux then you should learn how unicode chars are
encoded in UTF-8 (like in http://en.wikipedia.org/wiki/UTF-8) to make
your own algorithm.

There is a very good chance it will work fine for you. Every ISO-8859-1
document with non-ASCII chars I try to open with UTF-8 editors gives me
errors.

What do you think?

Besides that, I know that there are a few probabilistic methods to
determine the charset a text is encoded. Mozilla Firefox uses them a
lot. There are many papers on this subject on the internet. Google is
your friend.

Best regards,
Daniel Colchete



Re: [sqlite] A littel question...

2006-07-21 Thread Daniel van Ham Colchete
Cesar David Rodas Maldonado wrote:
> Hello to everybody
>
> If I  have a table with 100.000 unique words I am wondering if SQLite
> select
> if faster an cheaper (RAM, Processor, etc), or If i have to help SQLite
> using a Hash function, and what could be that Hash function?
>
> Thanks.
>
Cesar,

you should consider using an index:
http://www.sqlite.org/lang_createindex.html

Best regards,
Daniel Colchete



Re: [sqlite] Using prepare, step, finalize and handling BUSY answers

2006-07-21 Thread Daniel van Ham Colchete
Jay Sprenkle wrote:
> Here's some example code:
>
> sqlite3*db;
>
> // connect to database
> if ( sqlite3_open( "test.db",  ) )
>   throw "Can't open database";
>
> char* sql;
>
> // two forms of the same sql
> sql = "SELECT one.test1, two.test2"
>  " FROM one"
>  " INNER JOIN two ON one.id = two.id"
>  ;
> sqlite3_stmt*   pStmt;
>
> if ( sqlite3_prepare( db, sql, strlen(sql), , NULL ) != SQLITE_OK )
>   {
>  string str = "Cannot prepare sql: ";
>  str += sql[t];
>  str += ", Error: ";
>  str += sqlite3_errmsg(db);
>  throw str.c_str();
>   }
>
> bool Loop = true;
> while ( Loop )
>   switch ( sqlite3_step( pStmt ) )
>  {
> case SQLITE_ROW:
>// retrieve the results
>char* p = (char *) sqlite3_column_text( pStmt, 0 );
>string test1  = string( p ? p : "" );
>
>p = (char *) sqlite3_column_text( pStmt, 1 );
>string test2 = string( p ? p : "" );
>
>break;
> case SQLITE_DONE:
>Loop = false;
>break;
> case SQLITE_BUSY:
> case SQLITE_LOCKED:
> default:
>string str = "Cannot execute sql: ";
>str += sql[t];
>str += ", Error: ";
>str += sqlite3_errmsg(db);
>throw str.c_str();
>break;
>  }
>
> // clean up when finished
> sqlite3_finalize( pStmt );
>
> sqlite3_close( db );

Jay, thank you very much man! That answers a lot. And it showed me that
I was not checking the SQLITE_LOCKED case.

But, from what I can see, if your database is busy or locked you just
stop your program execution, or you will end this function WITHOUT
running neither sqlite3_finalize nor sqlite3_close. Either way you will
have a memory leak and this is not a good thing when you're running an
daemon (my case).

What if you put an loop = false instead of the throw at the 'default'
case? Do you have to you use sqlite3_interrupt before sqlite3_finalize?

Best regards,
Daniel Colchete



[sqlite] Using prepare, step, finalize and hadling BUSY answers

2006-07-21 Thread Daniel van Ham Colchete
Hello everyone,

I'm new on this list and I have only a few months of experience with
SQLITE. I use SQLITE 3.3.6 for Linux with C++.

I'm having a few problems with locking. But before describing the
problem itself, I would like to check if I'm doing something wrong.

That's what I do when I try to INSERT something in my database:

PREPARE
BIND
EC = STEP
while EC = BUSY {
  TRY AGAIN 10 TIMES; // SQLITE is set to sleep 1 sec if BUSY.
  IF TIME > 10 { BREAK; }
}

And then I do some other selects and inserts. Now I read that there is
another function I should be using: sqlite3_finalize. From what I
understood I should be doing:

PREPARE
BIND
EC = STEP
while EC = BUSY {
  TRY AGAIN 10 TIMES; // SQLITE is set to sleep 1 sec if BUSY.
  IF TIME > 10 { BREAK; }
}
FINALIZE

Am I right?

Question: what if a PREPARE returns BUSY? What should I do? Why would a
PREPARE return BUSY?

I'm having problems understanding the SQLite docs. At the 'C/C++
Interface for SQLite Version 3' it says that sqlite3_exec is a wrapper
to 'prepare, finalize, reset' without a step. But a little bit down the
document it says you should use and step. But again, what if I don't
want to wait the busy state anymore? Should I use finalize or interrupt
and then finalize?

Thank you very much for your help!

Best regards,
Daniel Colchete