Re: [sqlite] sqlite3_exec return an error message

2008-04-23 Thread Joanne Pham
Hi Igor,
Previous email you mentioned :
>  SQLite won't read the file for you, you will have to do it yourself (and
>  probably strip all dot commands from it before passign the contents to
>  sqlite3_exec).

>  Alternatively, just shell out to sqlite3 utility with an appropriate
>  command line.
>

What do you meant by "probably strip all dot commands from it before passign 
the contents to
>  sqlite3_exec)."
Thanks,
JP




- Original Message 
From: Joanne Pham <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]; General Discussion of SQLite Database 

Sent: Wednesday, April 23, 2008 5:02:17 PM
Subject: Re: [sqlite] sqlite3_exec return an error message

Thanks to both of you!
Sorry I am new baby to sqlite3.
Now I got it.
So I should use the shell script to execute these commands.

Thanks,
Joanne



- Original Message 
From: P Kishor <[EMAIL PROTECTED]>
To: General Discussion of SQLite Database 
Sent: Wednesday, April 23, 2008 4:55:30 PM
Subject: Re: [sqlite] sqlite3_exec return an error message

On 4/23/08, Joanne Pham <[EMAIL PROTECTED]> wrote:
> Thanks a lot Igor!
>  But the codes below didn't work too:
>  char stmt[STMT_LEN];
>  char *sqlStmt = &stmt[0];
>  strcpy(&stmt[0],"output compressTable; mode csv;  select * from 
> compressTable;  ");
>
>  sqlSt= sqlite3_exec(pDb,sqlStmt , NULL, 0, &errMsg);
>  if (sqlSt != SQLITE_OK ) {
>WXLOGE(LOG_SYSLOG_ON, WX_MODULE_ID_MGMT, 
> WX_SUBMOD_ID_MGMT_MONREPORT,
>"%s: - Error = %s - ",__FUNCTION__, errMsg);
>sqlite3_free(errMsg);
>bRet= false;
>  }
>
>  So how to set the output and mode before executing the select statement.
>  Thanks a ton,

Think of what you are doing, and read what Igor is trying to tell you.
You are mixing two technologies... but are limited by their individual
limitations -- the SQLite shell that implements the dot commands and
the SQL C API that works with the sqlite library.

Try to do all your output compress csv dance in C, or use a more
flexible development environment (Perl, Python, Tcl, whatever) to
accomplish the entire task.


>
> JP
>
>
>
>  - Original Message 
>  From: Igor Tandetnik <[EMAIL PROTECTED]>
>  To: sqlite-users@sqlite.org
>  Sent: Wednesday, April 23, 2008 4:03:20 PM
>  Subject: Re: [sqlite] sqlite3_exec return an error message
>
>  Joanne Pham <[EMAIL PROTECTED]> wrote:
>  > I have the following codes to execute the sql file but the error
>  > message return back that dot(.).
>  > It seems like sqlite3_exec didn't like ".output wanPerfTableTest".
>  > So how go to get arround with this command ".output wanPerfTableTest"
>  >
>  > strcpy(&stmt[0],".read /tmp/dump_WAN.sql");
>  > if (bIsConnected) {
>  >  sqlSt= sqlite3_exec(pDb,stmt , NULL, 0, &errMsg);
>  >  if (sqlSt != SQLITE_OK ) {
>  >  ...
>  >  }
>  > }
>
>  Dot commands (.output and, for that matter, .read) are interpreted by
>  sqlite3 command line utility - not by SQLite engine. They are not valid
>  SQL statements. sqlite3_exec complains about .read already, it never
>  actually reads the file (so the presence of .output in the file is
>  irrelevant).
>
>  SQLite won't read the file for you, you will have to do it yourself (and
>  probably strip all dot commands from it before passign the contents to
>  sqlite3_exec).
>
>  Alternatively, just shell out to sqlite3 utility with an appropriate
>  command line.
>
>  Igor Tandetnik
>
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


  

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


  

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] sqlite3_exec return an error message

2008-04-23 Thread Joanne Pham
Thanks to both of you!
Sorry I am new baby to sqlite3.
Now I got it.
So I should use the shell script to execute these commands.

Thanks,
Joanne



- Original Message 
From: P Kishor <[EMAIL PROTECTED]>
To: General Discussion of SQLite Database 
Sent: Wednesday, April 23, 2008 4:55:30 PM
Subject: Re: [sqlite] sqlite3_exec return an error message

On 4/23/08, Joanne Pham <[EMAIL PROTECTED]> wrote:
> Thanks a lot Igor!
>  But the codes below didn't work too:
>  char stmt[STMT_LEN];
>  char *sqlStmt = &stmt[0];
>  strcpy(&stmt[0],"output compressTable; mode csv;  select * from 
> compressTable;  ");
>
>  sqlSt= sqlite3_exec(pDb,sqlStmt , NULL, 0, &errMsg);
>  if (sqlSt != SQLITE_OK ) {
>WXLOGE(LOG_SYSLOG_ON, WX_MODULE_ID_MGMT, 
> WX_SUBMOD_ID_MGMT_MONREPORT,
>"%s: - Error = %s - ",__FUNCTION__, errMsg);
>sqlite3_free(errMsg);
>bRet= false;
>  }
>
>  So how to set the output and mode before executing the select statement.
>  Thanks a ton,

Think of what you are doing, and read what Igor is trying to tell you.
You are mixing two technologies... but are limited by their individual
limitations -- the SQLite shell that implements the dot commands and
the SQL C API that works with the sqlite library.

Try to do all your output compress csv dance in C, or use a more
flexible development environment (Perl, Python, Tcl, whatever) to
accomplish the entire task.


>
> JP
>
>
>
>  - Original Message 
>  From: Igor Tandetnik <[EMAIL PROTECTED]>
>  To: sqlite-users@sqlite.org
>  Sent: Wednesday, April 23, 2008 4:03:20 PM
>  Subject: Re: [sqlite] sqlite3_exec return an error message
>
>  Joanne Pham <[EMAIL PROTECTED]> wrote:
>  > I have the following codes to execute the sql file but the error
>  > message return back that dot(.).
>  > It seems like sqlite3_exec didn't like ".output wanPerfTableTest".
>  > So how go to get arround with this command ".output wanPerfTableTest"
>  >
>  > strcpy(&stmt[0],".read /tmp/dump_WAN.sql");
>  > if (bIsConnected) {
>  >  sqlSt= sqlite3_exec(pDb,stmt , NULL, 0, &errMsg);
>  >  if (sqlSt != SQLITE_OK ) {
>  >  ...
>  >  }
>  > }
>
>  Dot commands (.output and, for that matter, .read) are interpreted by
>  sqlite3 command line utility - not by SQLite engine. They are not valid
>  SQL statements. sqlite3_exec complains about .read already, it never
>  actually reads the file (so the presence of .output in the file is
>  irrelevant).
>
>  SQLite won't read the file for you, you will have to do it yourself (and
>  probably strip all dot commands from it before passign the contents to
>  sqlite3_exec).
>
>  Alternatively, just shell out to sqlite3 utility with an appropriate
>  command line.
>
>  Igor Tandetnik
>
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


  

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] sqlite3_exec return an error message

2008-04-23 Thread P Kishor
On 4/23/08, Joanne Pham <[EMAIL PROTECTED]> wrote:
> Thanks a lot Igor!
>  But the codes below didn't work too:
>  char stmt[STMT_LEN];
>   char *sqlStmt = &stmt[0];
>  strcpy(&stmt[0],"output compressTable; mode csv;  select * from 
> compressTable;  ");
>
>   sqlSt= sqlite3_exec(pDb,sqlStmt , NULL, 0, &errMsg);
>   if (sqlSt != SQLITE_OK ) {
>WXLOGE(LOG_SYSLOG_ON, WX_MODULE_ID_MGMT, 
> WX_SUBMOD_ID_MGMT_MONREPORT,
> "%s: - Error = %s - ",__FUNCTION__, errMsg);
>sqlite3_free(errMsg);
>bRet= false;
>   }
>
>  So how to set the output and mode before executing the select statement.
>  Thanks a ton,

Think of what you are doing, and read what Igor is trying to tell you.
You are mixing two technologies... but are limited by their individual
limitations -- the SQLite shell that implements the dot commands and
the SQL C API that works with the sqlite library.

Try to do all your output compress csv dance in C, or use a more
flexible development environment (Perl, Python, Tcl, whatever) to
accomplish the entire task.


>
> JP
>
>
>
>  - Original Message 
>  From: Igor Tandetnik <[EMAIL PROTECTED]>
>  To: sqlite-users@sqlite.org
>  Sent: Wednesday, April 23, 2008 4:03:20 PM
>  Subject: Re: [sqlite] sqlite3_exec return an error message
>
>  Joanne Pham <[EMAIL PROTECTED]> wrote:
>  > I have the following codes to execute the sql file but the error
>  > message return back that dot(.).
>  > It seems like sqlite3_exec didn't like ".output wanPerfTableTest".
>  > So how go to get arround with this command ".output wanPerfTableTest"
>  >
>  > strcpy(&stmt[0],".read /tmp/dump_WAN.sql");
>  > if (bIsConnected) {
>  >  sqlSt= sqlite3_exec(pDb,stmt , NULL, 0, &errMsg);
>  >  if (sqlSt != SQLITE_OK ) {
>  >  ...
>  >  }
>  > }
>
>  Dot commands (.output and, for that matter, .read) are interpreted by
>  sqlite3 command line utility - not by SQLite engine. They are not valid
>  SQL statements. sqlite3_exec complains about .read already, it never
>  actually reads the file (so the presence of .output in the file is
>  irrelevant).
>
>  SQLite won't read the file for you, you will have to do it yourself (and
>  probably strip all dot commands from it before passign the contents to
>  sqlite3_exec).
>
>  Alternatively, just shell out to sqlite3 utility with an appropriate
>  command line.
>
>  Igor Tandetnik
>
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] sqlite3_exec return an error message

2008-04-23 Thread Igor Tandetnik
Joanne Pham <[EMAIL PROTECTED]> wrote:
> Thanks a lot Igor!
> But the codes below didn't work too:
> char stmt[STMT_LEN];
> char *sqlStmt = &stmt[0];
> strcpy(&stmt[0],"output compressTable; mode csv;  select * from
> compressTable;  ");

I didn't say the dot in front is wrong: the whole command is wrong. 
Neither "output compressTable;" nor ".output compressTable;" are valid 
SQL statements.

> So how to set the output and mode before executing the select
> statement.

What output and mode? sqlite3_exec doesn't produce any output.

Again - you are confusing SQLite API and sqlite3 command line utility 
built on top of that API.

Igor Tandetnik 



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


Re: [sqlite] sqlite3_exec return an error message

2008-04-23 Thread Joanne Pham
Thanks a lot Igor!
But the codes below didn't work too:
char stmt[STMT_LEN];
 char *sqlStmt = &stmt[0];
strcpy(&stmt[0],"output compressTable; mode csv;  select * from compressTable;  
");
 
  sqlSt= sqlite3_exec(pDb,sqlStmt , NULL, 0, &errMsg);
  if (sqlSt != SQLITE_OK ) {
   WXLOGE(LOG_SYSLOG_ON, WX_MODULE_ID_MGMT, WX_SUBMOD_ID_MGMT_MONREPORT,
"%s: - Error = %s - ",__FUNCTION__, errMsg); 
   sqlite3_free(errMsg);
   bRet= false;
  } 

So how to set the output and mode before executing the select statement.
Thanks a ton,
JP


- Original Message 
From: Igor Tandetnik <[EMAIL PROTECTED]>
To: sqlite-users@sqlite.org
Sent: Wednesday, April 23, 2008 4:03:20 PM
Subject: Re: [sqlite] sqlite3_exec return an error message

Joanne Pham <[EMAIL PROTECTED]> wrote:
> I have the following codes to execute the sql file but the error
> message return back that dot(.).
> It seems like sqlite3_exec didn't like ".output wanPerfTableTest".
> So how go to get arround with this command ".output wanPerfTableTest"
>
> strcpy(&stmt[0],".read /tmp/dump_WAN.sql");
> if (bIsConnected) {
>  sqlSt= sqlite3_exec(pDb,stmt , NULL, 0, &errMsg);
>  if (sqlSt != SQLITE_OK ) {
>  ...
>  }
> }

Dot commands (.output and, for that matter, .read) are interpreted by 
sqlite3 command line utility - not by SQLite engine. They are not valid 
SQL statements. sqlite3_exec complains about .read already, it never 
actually reads the file (so the presence of .output in the file is 
irrelevant).

SQLite won't read the file for you, you will have to do it yourself (and 
probably strip all dot commands from it before passign the contents to 
sqlite3_exec).

Alternatively, just shell out to sqlite3 utility with an appropriate 
command line.

Igor Tandetnik



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


  

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] sqlite3_exec return an error message

2008-04-23 Thread Igor Tandetnik
Joanne Pham <[EMAIL PROTECTED]> wrote:
> I have the following codes to execute the sql file but the error
> message return back that dot(.).
> It seems like sqlite3_exec didn't like ".output wanPerfTableTest".
> So how go to get arround with this command ".output wanPerfTableTest"
>
> strcpy(&stmt[0],".read /tmp/dump_WAN.sql");
> if (bIsConnected) {
>  sqlSt= sqlite3_exec(pDb,stmt , NULL, 0, &errMsg);
>  if (sqlSt != SQLITE_OK ) {
>   ...
>  }
> }

Dot commands (.output and, for that matter, .read) are interpreted by 
sqlite3 command line utility - not by SQLite engine. They are not valid 
SQL statements. sqlite3_exec complains about .read already, it never 
actually reads the file (so the presence of .output in the file is 
irrelevant).

SQLite won't read the file for you, you will have to do it yourself (and 
probably strip all dot commands from it before passign the contents to 
sqlite3_exec).

Alternatively, just shell out to sqlite3 utility with an appropriate 
command line.

Igor Tandetnik



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


[sqlite] sqlite3_exec return an error message

2008-04-23 Thread Joanne Pham
Hi All,
I have the following codes to execute the sql file but the error message return 
back that dot(.).
It seems like sqlite3_exec didn't like ".output wanPerfTableTest".
So how go to get arround with this command ".output wanPerfTableTest" 
Your help is greatly appreciated.
Thanks
JP

strcpy(&stmt[0],".read /tmp/dump_WAN.sql");
 if (bIsConnected) {
  sqlSt= sqlite3_exec(pDb,stmt , NULL, 0, &errMsg);
  if (sqlSt != SQLITE_OK ) {
   ...
  } 
 }

my file is defined as:
attach database 'CommonDB' as CDB;
.output wanPerfTableTest
.mode csv
select datetime('now');
select startTime, appName, appType, isAppDeleted, remoteWXId, hostName
remoteWXType, active, bytesToWan, bytesFromWan from wanPerfTable
JOIN CDB.appMapTable on wanPerfTable.appId = CDB.appMapTable.appId JOIN
CDB.remoteWXTable on wanPerfTable.remoteId = CDB.remoteWXTable.remoteId;
detach database CDB;
select datetime('now');


  

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] How to execute the statment file using sqlite API

2008-04-23 Thread Joanne Pham
Thanks for the info.
So I don't want to read the file into array and executes it.
I have the define the array of characters as below:
.output outputFile.mode csv select startTime, appName, appType, 
isAppDeleted, remoteWXId;
but it didn't work. 
Can you please help.
Thanks,
JP


- Original Message 
From: Fin Springs <[EMAIL PROTECTED]>
To: sqlite-users@sqlite.org
Sent: Wednesday, April 23, 2008 6:25:12 AM
Subject: Re: [sqlite] How to execute the statment file using sqlite API


On Apr 22, 2008, at 7:57 PM, Joanne Pham joannekpham-at-yahoo.com | 
sqlite| wrote:

> Hi all,
> I have the serveral sql statement in the one file call : getData.sql  
> and
> I want to use the sqlite API to call this file to execute all sql  
> statements in this file at once.
>
> Can you tell me what API I should use.
> I had the code to execute the statment but I don't know how to call  
> the file.
> Below is my code to execute the single statement.
> sqlSt = sqlite3_open( name, &pDb);
> strcpy(&stmt[0], "Select * from my table");
> sqlSt = sqlite3_exec(pDb, sqlStmt, NULL, 0, &errMsg) ;
> 
>
If you can read the whole file into a character array then you can  
execute it all in a single sqlite3_exec call. That is, sqlite3_exec  
will process multiple statements in a single string, such as "SELECT *  
FROM my_table; SELECT * FROM my_other_table;". Or, you could read the  
file line by line and pass each line to exec, if you know that each  
line contains a complete SQL statement.

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


  

Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Trigger on an attached db.

2008-04-23 Thread Federico Granata
Doing it in my app means polling the other db instead of receive an
"interrupt" via trigger ... I can do it but it's the "polling vs interrupt"
...
Obviously I prefer to sit and wait for data instead of looping looking for
data but if it's the only way ...

--
[image: Just A Little Bit Of
Geekness]
Le tre grandi virtù di un programmatore: pigrizia, impazienza e arroganza.
(Larry Wall).

On Wed, Apr 23, 2008 at 3:01 PM, P Kishor <[EMAIL PROTECTED]> wrote:

> On 4/23/08, Federico Granata <[EMAIL PROTECTED]> wrote:
> > On Wed, Apr 23, 2008 at 12:22 AM, Igor Tandetnik <[EMAIL PROTECTED]>
> >  wrote:
> >
> >
> >  > Each connection has its own independent temp database. You've created
> a
> >  > temporary trigger which exists in the temp database for your
> connection.
> >  > The trigger simply doesn't exist on the other connection.
> >  >
> >
> > damn ...
> >
> >
> >  Yes, if that other session attaches the appropriate database and
> creates
> >  > an appropriate trigger. No, you cannot magically alter the behavior
> of
> >  > another application you have no control over.
> >  >
> >
> > I don't want to alter the behavior of the other app nor I want to alter
> his
> >  db.
> >  If I create mine table and trigger in the B db everything run smooth
> but I
> >  try to "hook" on some event without disturbing the original behavior.
> >  It's possible at all ?
> >
> ..
>
> do it in your application rather than at the db level.
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Blob truncation

2008-04-23 Thread Dennis Cote
[EMAIL PROTECTED] wrote:
> Is there a way to truncate a blob (for example set it size to the file
> size before compression and after inserting the compressed data to
> truncate the unused blob space)? Or it is possible to change the blob size
> "on the fly"?
> 
> Any help is very welcome and thank you in advice!
> 

Please don't hijack threads on other topics.

http://en.wikipedia.org/wiki/Thread_hijacking

You can't truncate or resize a blob, but you can replace it with another 
blob with a different size. Your problem is that you don't know the size 
of the compressed blob until after you have done the compression (Note 
truncation may not always work if the compressor actually ends up 
expanding a previously compressed file).

If you can get the compressed size of the file (i.e. by doing a dummy 
compression with output sent to a null device) you can then set the size 
of the blob correctly before you start writing to it.

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


Re: [sqlite] How to execute the statment file using sqlite API

2008-04-23 Thread Fin Springs

On Apr 22, 2008, at 7:57 PM, Joanne Pham joannekpham-at-yahoo.com | 
sqlite| wrote:

> Hi all,
> I have the serveral sql statement in the one file call : getData.sql  
> and
> I want to use the sqlite API to call this file to execute all sql  
> statements in this file at once.
>
> Can you tell me what API I should use.
> I had the code to execute the statment but I don't know how to call  
> the file.
> Below is my code to execute the single statement.
> sqlSt = sqlite3_open( name, &pDb);
> strcpy(&stmt[0], "Select * from my table");
> sqlSt = sqlite3_exec(pDb, sqlStmt, NULL, 0, &errMsg) ;
> 
>
If you can read the whole file into a character array then you can  
execute it all in a single sqlite3_exec call. That is, sqlite3_exec  
will process multiple statements in a single string, such as "SELECT *  
FROM my_table; SELECT * FROM my_other_table;". Or, you could read the  
file line by line and pass each line to exec, if you know that each  
line contains a complete SQL statement.

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


Re: [sqlite] Trigger on an attached db.

2008-04-23 Thread P Kishor
On 4/23/08, Federico Granata <[EMAIL PROTECTED]> wrote:
> On Wed, Apr 23, 2008 at 12:22 AM, Igor Tandetnik <[EMAIL PROTECTED]>
>  wrote:
>
>
>  > Each connection has its own independent temp database. You've created a
>  > temporary trigger which exists in the temp database for your connection.
>  > The trigger simply doesn't exist on the other connection.
>  >
>
> damn ...
>
>
>  Yes, if that other session attaches the appropriate database and creates
>  > an appropriate trigger. No, you cannot magically alter the behavior of
>  > another application you have no control over.
>  >
>
> I don't want to alter the behavior of the other app nor I want to alter his
>  db.
>  If I create mine table and trigger in the B db everything run smooth but I
>  try to "hook" on some event without disturbing the original behavior.
>  It's possible at all ?
>
..

do it in your application rather than at the db level.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Blob truncation

2008-04-23 Thread Robert Bielik
[EMAIL PROTECTED] skrev:
> 
> Any help is very welcome and thank you in advice!

The way I did it was to do a dummy write with a null device that just did:

int write(const void * data, int dataLength)
{
blobLength += dataLength;
}

Then I used that length with sqlite3_bind_zeroblob and made the real write 
operation.

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


[sqlite] Blob truncation

2008-04-23 Thread vasil
Hello,

I am trying to implement a simple file store based on the SQLite library.
The idea is to use the SQLite as virtual folder. The logic is quite simple
except the following detail:

I need to read the files block by block (with 64k buffer size) and process
each block with the zlib before storing it in the SQLite base. The actual
problem is the blob buffer allocation with sqlite3_bind_zeroblob - I don't
know the real file size after the blocks are compressed so i can not
specify the blob size.
Is there a way to truncate a blob (for example set it size to the file
size before compression and after inserting the compressed data to
truncate the unused blob space)? Or it is possible to change the blob size
"on the fly"?

Any help is very welcome and thank you in advice!


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


Re: [sqlite] sqlite DB on a CD

2008-04-23 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Lauri Ojansivu wrote:
> Another option is to buy Molebox that encrypts vb exe, sqlite database
> and other files to single packed exe where reading sqlite database
> from encrypted exe works like it was in same directory without any
> encryption, and database is not extracted to disk in any phase.

A better question for the original poster is how much would you want a
bad guy to have to spend (time, tools, expertise) in order to get the
contents of your database.

If you just want to obfuscate things then you can write your own vfs
that knows how to unobfuscate the data (doing something as trivial as
xorring each page with a different value would be sufficient).  It would
cost the bad guy up to a few hundred dollars (mostly time).

If you have used something like Molebox then it will cost them a few
thousand if it hasn't been cracked already in which case it is back to a
few hundred.  Remember they have all the time in the world to do this
(eg they can take two years - will a two year old version of the
database be useful to bad guys?).  But most of those products are
cracked since they product multiple other people's products so cracking
the scheme itself gets you multiple results.  A quick google shows that
Molebox itself has been cracked, serial keygenned etc to various degrees.

To get beyond this point you can only do so by offering the data as an
online service (ie authenticating each request and limiting the
response) or having complete hardware control over the environment in
which the program is done.  (The encryption keys and code have to exist
on the machine at some point so a determined cracker can get them.)

In general the way this whole problem is normally solved is by treating
your customers well, offering good value, spending the money you would
have spent on these harebrained schemes on making a better product,
having frequent updates, being a leader in your product space etc.

Roger
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFIDxD0mOOfHg372QQRAjKNAJ9yyt/QSckGZsj5I1Q1XsEnQx+jPgCdGSMO
yHaTmJYqsQzu0K2oQJBLzQ8=
=Z37t
-END PGP SIGNATURE-
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] sqlite DB on a CD

2008-04-23 Thread Gregory Letellier
if your databse was not bigger you can put your sql dump in the zip and 
construct a memory database with this dump

- Original Message - 
From: "Lauri Ojansivu" <[EMAIL PROTECTED]>
To: "General Discussion of SQLite Database" 
Sent: Wednesday, April 23, 2008 12:12 PM
Subject: Re: [sqlite] sqlite DB on a CD


> 2008/4/22  <[EMAIL PROTECTED]>:
>> Hi,
>>  I like to distribute my application on a CD.
>>  This application has a sqlite database which will be part of the
>>  distribution.
>>  I do not like anybody reading/accesing the database directly, so I put
>>  the database file inside a zip file which is password protected.
>>  My application is written in VB, and I have hard coded the password
>>  inside the VB program.
>>  When the application loads, it opens the password protected zip file,
>>  and extracts the sqlite file within it.
>>  Now, I do not want to write this db file to any temporary location on
>>  the hard disk. Is it possible to load the entire sqlite file in memory
>>  and the application read data from it?
>
> Another option is to buy Molebox that encrypts vb exe, sqlite database
> and other files to single packed exe where reading sqlite database
> from encrypted exe works like it was in same directory without any
> encryption, and database is not extracted to disk in any phase.
>
> - Lauri
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users 

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


Re: [sqlite] sqlite DB on a CD

2008-04-23 Thread Lauri Ojansivu
2008/4/22  <[EMAIL PROTECTED]>:
> Hi,
>  I like to distribute my application on a CD.
>  This application has a sqlite database which will be part of the
>  distribution.
>  I do not like anybody reading/accesing the database directly, so I put
>  the database file inside a zip file which is password protected.
>  My application is written in VB, and I have hard coded the password
>  inside the VB program.
>  When the application loads, it opens the password protected zip file,
>  and extracts the sqlite file within it.
>  Now, I do not want to write this db file to any temporary location on
>  the hard disk. Is it possible to load the entire sqlite file in memory
>  and the application read data from it?

Another option is to buy Molebox that encrypts vb exe, sqlite database
and other files to single packed exe where reading sqlite database
from encrypted exe works like it was in same directory without any
encryption, and database is not extracted to disk in any phase.

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