Re: [sqlite] does sqlite support mutil-thread be run in samedatabase?

2007-01-18 Thread LuYanJun
But I still get orignal error message, a pice of code as follow, suppose all 
routines open the same database:
void fillSchedule(void *param)
{
   Open();
   ...
   Close();
}
void fillCredits(void *param)
{
   Open();
   ...
   Close();
}
int main(void)
{
  Open()
  ...
  Close();
  hThreadSchedule = CreateThread(..., fillSchedule, ...);
  hThreadCredits = CreateThread(..., fillCredits, ...);
  
  WaitForSingleObject(.., hThreadSchedule,...);
  WaitForSingleObject(.., hThreadCredits,...);
}
So does the through is right?
- Original Message - 
From: "Dan Kennedy" <[EMAIL PROTECTED]>
To: <sqlite-users@sqlite.org>
Sent: Friday, January 19, 2007 1:08 PM
Subject: Re: [sqlite] does sqlite support mutil-thread be run in samedatabase?


> 
> On Fri, 2007-01-19 at 11:42 +0800, LuYanJun wrote:
>> The next question is that if I want to use multi-thread in sqlite, so
>> I need to open same database for two times, right?
> 
> Right. Each thread has to have it's own sqlite3* handle.
> 
> 
>> - Original Message - 
>> From: "LuYanJun" <[EMAIL PROTECTED]>
>> To: "sqlite-users sqlite.org" <sqlite-users@sqlite.org>
>> Sent: Friday, January 19, 2007 10:53 AM
>> Subject: [sqlite] does sqlite support mutil-thread be run in same database?
>> 
>> 
>> > Hi guys
>> >   does sqlite support mutil-thread be run in same database? because of I 
>> > am stuck in such below sqlite error message:
>> > error number = 21
>> > error message = library routine called out of sequence
>> >  certainly, I get some useful hints from stuff about interface of SQLite, 
>> > but I am not sure that weather sqlite support multi-thread.
>> > Tks in advance.
> 
> 
> -
> To unsubscribe, send email to [EMAIL PROTECTED]
> -
> 
>

[sqlite] SELECT * FROM Schdeule WHERE title LIKE '%%%'

2006-12-21 Thread LuYanJun
Hi guy
   Suppose there is table name Schedule and more than two records be stored. 
however, one filed name as title and its values contain '%' in one of both 
records , so then such SQL pharse: SELECT * FROM Schedule WHERE title LIKE 
'%%%' be given  , then return both records NOT only one .
example:
.. | .. | title| ...
.. | .. | I hate you % | ...
.. | .. | I love you   | ...
so what's problem come with me? 
 

Re: [sqlite] SQL error: near "READ_ONLY": syntax error

2006-12-18 Thread LuYanJun
Thanks, But I step the instruction fellow the hint by offcial document by which 
said that's correct(BTW forgive me my poor english ):
http://www.sqlite.org/concurrency.html
4.1 Read-only transactions
BEGIN READ_ONLY;
SELECT * FROM t1;
SELECT * FROM t2;
COMMIT;

4.2 Defer write locks
BEGIN READ_INITIALLY;
SELECT * FROM t1;
SELECT * FROM t2;
COMMIT;
4.4 Defer writes
 BEGIN DEFER_WRITES;
SELECT * FROM t1;
-- Processing delay
UPDATE t1 SET ... WHERE ...
SELECT * FROM t2;
-- Processing delay
UPDATE t2 SET ... WHERE ...
SELECT * FROM t3;
-- Processing delay
UPDATE t3 SET ... WHERE ...
COMMIT;
...and so forth.

I wonder that does do something with version? 
- Original Message - 
From: "Marten Feldtmann" <[EMAIL PROTECTED]>
To: <sqlite-users@sqlite.org>
Sent: Monday, December 18, 2006 3:00 PM
Subject: Re: [sqlite] SQL error: near "READ_ONLY": syntax error


> LuYanJun schrieb:
>> Hi guy:
>> what does the follow meaning?
>> sqlite> BEGIN READ_ONLY;
>> SQL error: near "READ_ONLY": syntax error
> READ_ONLY is not a valid option for this command.
> 
> BEGIN [DEFERRED | EXCLUSIVE | IMMEDIATE]
> 
> Marten
> 
> -
> To unsubscribe, send email to [EMAIL PROTECTED]
> -
> 
>

[sqlite] SQL error: near "READ_ONLY": syntax error

2006-12-17 Thread LuYanJun
Hi guy:
what does the follow meaning?
sqlite> BEGIN READ_ONLY;
SQL error: near "READ_ONLY": syntax error

Re: [sqlite] Music Files

2006-11-29 Thread LuYanJun
Ok, Let me do it with C language
const unsigned char* Format(const char* szFormat, ...);
int AudioFillDatabase(const char* audiofile);
int main(void)
{
 Open();
  execDML(" CREATE TABLE IF NOT EXISTS AudioTable (id INTEGER , \n"
" name VARCHAR , \n"
  " data BLOB , \n"
  " type VARCHAR);");
AudoFillDatabase(SomeSongname.xxx);
Close();
exit(0);
}
int AudioFillDatabase(const char* audiofile)
{
   FILE* fp = fopen(audiofile, "rb");
   if ( fp == NULL )
  return -1;
   else {
  fseek(fp, 0, SEEK_END);
 long filesize = ftell(fp);
 unsigned char* MemFileSize = new unsigned char[filesize + 1];
  size_t ret = fread(MemFileSize, filesize, 1, fp);
  if ( ret != 0 )
 return -1;
  else {
 unsigned char* buf = new unsigned char[filesize+1024];
buf = Format("insert into AudioTable values (0, 'music', %Q, 'mp3');", 
MemFileSize);
   execDML(buf);
  }
 }
const char* format(const char* szFromat, ...)
{
   va_list va;
   va_start(va, szFormat);
   static char* mpBuf = sqlite3_vmprintf(szFormat, va);
   va_end(va);
   return mpBuf;
}
- Original Message - 
From: "Isaac Raway" <[EMAIL PROTECTED]>
To: <sqlite-users@sqlite.org>
Sent: Tuesday, November 28, 2006 11:04 PM
Subject: Re: [sqlite] Music Files


> On 11/27/06, LuYanJun <[EMAIL PROTECTED]> wrote:
>>
>> Can anybody give a simple example for domestrating ?
>> I am puzzled by this topic, how does a music file be sotred in DB as BLOB
>> type?
> 
> 
> You can insert /any/ kind of data into a SQLite database (or most any other
> sort of DB for that matter). Here's a short Pascal program that would do
> about what you want -- but of course getting the binary data out and into an
> object that can play it is another matter. Also I imagine this would be very
> slow, coming in at around 3 - 5 MB per song that has to be completely loaded
> into memory from the DB before playback and begin. I have not tested this
> but it gives you the idea: 1) load data into a stream / data string 2) write
> as DB BLOB.
> 
> var
>  MP3Source: string;
>  Data: TFileStream
> 
>  DBFileName: string;
>  DB: TSQLiteDatabase;
>  MustCreate: boolean;
> begin
>  MP3Source := 'SomeSong.mp3';
>  DBFileName := 'mp3.db3';
> 
>  MustCreate := not FileExists(DBFileName);
>  DB := TSQLiteDatabase.Create(DBFileName);
>  try
>if MustCreate then begin
>  DB.ExecSQL('CREATE TABLE mp3(filename STRING PRIMARY KEY, data
> BLOB);');
>end;
> 
>Data := TFileStream.Create(MP3Source, fmOpenRead);
>try
>  Data.Seek(0);
> 
>  DB.UpdateBlob('INSERT OR UPDATE INTO mp3(filename, data) ' +
>'VALUES(' + QuotedStr(MP3Source) + ', ?);', Data);
>finally
>  FreeAndNil(Data);
>end;
>  finally
>DB.Close;
>FreeAndNil(DB);
>  end;
> end;
>

Re: [sqlite] Music Files

2006-11-27 Thread LuYanJun
Can anybody give a simple example for domestrating ?
I am puzzled by this topic, how does a music file be sotred in DB as BLOB type?

TKS.
- Original Message - 
From: "Alex Roston" <[EMAIL PROTECTED]>
To: 
Sent: Saturday, October 28, 2006 4:35 AM
Subject: Re: [sqlite] Music Files


> At one point there was a project that did something like this, and it 
> was called Route66. I think it used mysql, perl and a player called 
> splay. You might google it.
> 
> Alex
> 
> sebcity wrote:
> 
>>Is it possible to store mp3 files in a SSQLite database? would they be able
>>to be played from the database? How would you save them?
>>  
>>
> 
> 
> -
> To unsubscribe, send email to [EMAIL PROTECTED]
> -
> 
>

[sqlite] Fw: Why can't I delete tmp.db after close sqlite?

2006-11-08 Thread LuYanJun
if the file is new for opening, then success for delete, in other hand, if the 
file is old for opening, then failed for delete. example as follow:
 sqlite3_open("tmp.db", ); //tmp.db is exist

- Original Message ----- 
From: LuYanJun 
To: sqlite-users sqlite.org 
Sent: Thursday, November 09, 2006 11:11 AM
Subject: Why can't I delete tmp.db after close sqlite?


Hi all
Why can't I delete tmp.db after close sqlite?

sqlite3* mpDB;
  int nRet = sqlite3_open("tmp.db", );
  if (nRet != SQLITE_OK)
  {
   const char* szError = sqlite3_errmsg(mpDB);
   printf("open error:%s\n",szError);
  }
  sqlite3_close(mpDB);
  printf("close!\n");
  if ( ! ::DeleteFile(tmp.db ))
  {
   printf("delete error!\n");
  }
  else
   printf("ok delete!!!\n");
  return 0; 

Best regards

[sqlite] Why can't I delete tmp.db after close sqlite?

2006-11-08 Thread LuYanJun
Hi all
Why can't I delete tmp.db after close sqlite?
 
sqlite3* mpDB;
  int nRet = sqlite3_open("tmp.db", );
  if (nRet != SQLITE_OK)
  {
   const char* szError = sqlite3_errmsg(mpDB);
   printf("open error:%s\n",szError);
  }
  sqlite3_close(mpDB);
  printf("close!\n");
  if ( ! ::DeleteFile(tmp.db ))
  {
   printf("delete error!\n");
  }
  else
   printf("ok delete!!!\n");
  return 0; 

Best regards