[sqlite] ascii separator character in .import

2010-01-19 Thread RevBayes

Hi all,
I was trying to use the .import tool in sqlite. I was wondering if there was
a way to specify any arbitrary ascii character via the .separator command.

e.g. if i want to use 0x05 (some non-printable ascii char) as the separator,
how do i specify it in the .separator command. 

regards,
Bayes
-- 
View this message in context: 
http://old.nabble.com/ascii-separator-character-in-.import-tp27236422p27236422.html
Sent from the SQLite mailing list archive at Nabble.com.

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


Re: [sqlite] Incremental i/o - Is anyone using ???sqlite3_blob_write????

2010-01-19 Thread a1rex
  >Look at the source for sqlite3_blob_open().


 
From stepping through the code I
have learned that  blob read/write fails and returns SQLITE_ABORT because  in 
the blob handle structure
 
structIncrblob {
  int flags;  /*
Copy of "flags" passed to qlite3_blob_open() */
  int nByte;  /*
Size of open blob, in bytes */
  int iOffset;/* Byte
offset of blob in cursor data */
  BtCursor *pCsr; /* Cursor pointing at blob row */
  sqlite3_stmt *pStmt;/* Statement holding cursor open */
  sqlite3 *db;/* The associated database */
};
 
 
pCstr->estate is turned to 0
(CURSOR_INVALID) by some previous Sqlite operation.


This forces invalidation of the statement ‘pStmt’  variable and subsequent 
return of the
SQLITE_ABORT code when first sqlite3BtreeData
is called by the blob_read:
 
SQLITE_PRIVATE int sqlite3BtreeData(BtCursor *pCur, u32 offset, u32
amt, void *pBuf){
  int rc;
 
#ifndefSQLITE_OMIT_INCRBLOB
  if (
pCur->eState==CURSOR_INVALID ){ //   
<-|

return SQLITE_ABORT; // 
<|
  }
#endif
 
//…
}
 
Now, if only I could guess what can force cursor eState to
CURSOR_INVALID value!? 
 
Thank you,
Samuel


  __
The new Internet Explorer® 8 - Faster, safer, easier.  Optimized for Yahoo!  
Get it Now for Free! at http://downloads.yahoo.com/ca/internetexplorer/
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] bug in proxyGetHostID()

2010-01-19 Thread Adam Swift
That code hasn't really been stress tested or qualified properly.  I submitted 
some changes to the os_unix.c sources to address this and some other issues 
(proxyGetHostID now uses the gethostuuid() system api).  The changes I 
submitted are significant and are still undergoing review prior to integration 
on trunk. I don't know if/when those changes will be pulled into the main 
repository trunk (I do know it's a significant effort to fully review, audit 
and ensure test & branch coverage).

- adam

On Jan 19, 2010, at 12:40 AM, Jens Miltner wrote:

> 
> Am 16.01.2010 um 19:00 schrieb Thomas Stüfe:
> 
>> Greetings,
>> 
>> I think I found a small bug in sqlite 3.6.22 in the function  
>> proxyGetHostID().
>> 
>> There, pread() and pwrite() are used to read a host id file. Return  
>> value of these functions is assigned to a size_t variable. size_t is  
>> unsigned. Should pread fail for any reason (IO Error or whatever)  
>> and return -1, the error handling would not kick in. Instead, the  
>> function would probably just leave the host id uninitialized and  
>> return ok.
>> 
>> A valid fix might be using ssize_t (signed size_t) instead of  
>> size_t, but I cannot of course say whether this would work on all  
>> platforms.
> 
> AFAICS, this is for Mac OS X only anyway...
> pread returns an ssize_t according to the docs, so the proposed change  
> looks safe to me...
> 
> Another potential problem is when for some reason the hostid file is  
> empty: in this case pread will return 0, which will leave pHostID  
> uninitialized, too.
> It will return a result code, but the OSTRACE3 inside proxyGetHostID  
> still attempts to dump the host ID, which at this point will be  
> uninitialized.
> 
> 
>> 
>> My Platform is MacOS X, I compile with gcc 4.2. I compile the  
>> amalgamation for sqlite 3.6.22. I only found this because gcc warns:
>> 
>> sqlite3.c:26120: warning: comparison of unsigned expression < 0 is  
>> always false
>> sqlite3.c:26134: warning: comparison of unsigned expression < 0 is  
>> always false
> 
> 
> 
> 
> ___
> 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] Limitation on Column count

2010-01-19 Thread Stefan_E

Hi Pavel,

yes - you are quite right, I wasn't precise here! Sorry about that!
What I meant was a join on unit_id, which obviously will have an index if
that's needed.

Thanks for your help!

Kind regards Stefan

Btw., in the same context, I noticed that sparse data of the database (with 
lots of NULL values), which would otherwise bloat the database doesn't seem
to be a problem in SQLite with it's type affinity scheme! Nice!

-- 
View this message in context: 
http://old.nabble.com/Limitation-on-Column-count-tp27117364p27231605.html
Sent from the SQLite mailing list archive at Nabble.com.

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


Re: [sqlite] Questions regaring SQLite support on N97

2010-01-19 Thread Pedro Brigatto
Well, I would like to thank you for the responses!! Thank you so much!

In terms of app development, well, I've heard things like that before, but
in this case the app is developed in java me, and I was just wondering if
there is any API that makes it possible to stablish a conversation between
sqlite databases and the app itself. Do you have any information that could
help?

I've been searching, but got nothing concrete/useful 'til now...

regards!
//pedro

On Tue, Jan 19, 2010 at 2:05 AM, Simon Slavin  wrote:

>
> On 19 Jan 2010, at 2:33am, Bill King wrote:
>
> > Things are getting better, qt and qtcreator for s60's making things
> > noticeably easier, and there's a QtSql wrapper for the sqlite server
> > engine access in the works, or native sqlite is included in qt/s60 by
> > default.
>
> That's all good news.  I tried developing for S60 about five years ago and
> gave up in disgust.  (I'm an experienced developer on both large and
> embedded, high-level and low-level systems, I didn't just wimp out at the
> first hurdle.)  Everything you mentioned there sounds like a huge
> improvement.
>
> Simon.
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>



-- 
Pedro Eugênio Cunha Brigatto
- Software Engineering Specialist -
- Sun Certified Java Programmer -
- SAP Netweaver Certified Java Consultant -
- Java ME Designer -
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Limitation on Column count

2010-01-19 Thread Pavel Ivanov
This is from your last e-mail:

> So, I can't see the advantage of normalization here. (Note that I do not
> plan to join or index
> on measurement columns!)

This is from your first e-mail:

> Queries on this big table will be rather straight-forward: either on the
> table alone (SELECT * FROM table_large) or one join on one field to one of
> the smaller tables.

As you probably can see these sentences contradict to each other.
If all queries that you need on your database are
- get all measurements for some unit_id;
- get some measurements for all unit_ids;
then of course you won't gain anything from normalization and your
queries will never contain any O(N^2) algorithms (because you have no
joins on measurements). So I'd say go ahead and raise the limit to
32K. Besides some ugly-looking column names and some schema
uncomfortable for database theory supporter, you won't get any
troubles with that.


Pavel

On Sun, Jan 17, 2010 at 6:08 PM, Stefan_E  wrote:
>
> Hi all,
>
> based on Pavels input, I did some quick trials and thought I let you know
> the results.
> I'm running on an old pentiu...@3.2ghz with 3G memory and Win-7. So, don't
> expect
> super-fast times!
>
> 1. I have one DB with 5411 units and 1517 measurements with columns
>       unit_id, m_1, .. m_1517
>    No indices and not 100% populated: .db size is 48'834kB, whereas for
> full population
>    I'd expect 5411*1517*8 = 65'668kB.
>
>    To dump the entire db into a .csv file with sqlite3.exe takes ~35s
>    To dump a random column takes 0.42 .. 1.02s with a mean of 0.65s
>    To dump 5 randomly selected columns takes 0.65 .. 1.16s with mean 0.88s
>    To dump 100 randomly selected columns takes 2.34 .. 3.11s with mean
> 2.54s
>    (I always dump all units and the times include the time to start sqlite3
> - so it could be improved...;
>     The run on one column shows the most dispersion and it is not clear
> which columns cost most...
>     Each series above includes 100 random selections)
>
> 2. I quickly created a DB for 5500 units and 1500 measurements in the format
>       unit_id, meas_id, meas_val
>    This database is fully populated with random values for meas_val and is
> 191MByte in size.
>    Dumping the whole db costs 77s, but this may be an unfair measurement
> since I simply run
>       select * from table;
>    rather than restoring the rectangular format of units x measurements.
>
>    Of course, now dumping one meas_id for all unit_id is expensive, so I
> need an index on meas_id
>    to run queries like 'select * from table where meas_id=n'. That
> increases .db size to 293MByte.
>    Likely, I'd need another index on unit_id as well... so db size would
> grow another 100MByte,
>    which I clearly woudn't like!
>
>    With the index, dumping one meas_id with the query above costs 0.61s (I
> didn't do multiple
>    runs here...), but if I now want to select multiple meas_id with queries
> like
>        select * from table where meas_id IN (n1, n2, ..)
>    it costs for 5 meas_id 1.62s and for 100 meas_id 27.2s (!!), so I'm
> penalized not only in
>    size but also in time compared to case 1 above.
>
> So, I can't see the advantage of normalization here. (Note that I do not
> plan to join or index
> on measurement columns!)
>
> So, back to my first question... what do I pay when I increase the compile
> time limits of SQLite
> from 2000 to 32k columns? To be honest, I still consider staying in the 2000
> column limit with
> a blocked table layout similar as follows:
>     unit_id, block_id, meas_1,  meas_2000
> so that measurements 2001 ... 4000 would come on a new row. (Yea, that's
> 2002 cols, so I need
> take care... :-) )
>
> Thanks for your help anyway - and let me know if you have further input or
> remarks, either regarding
> above measurements (did I miss some important stuff?) or for the case of
>>2000 measurements.
>
> Greetings - Stefan
>
> --
> View this message in context: 
> http://old.nabble.com/Limitation-on-Column-count-tp27117364p27203919.html
> Sent from the SQLite mailing list archive at Nabble.com.
>
> ___
> 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] Incremental i/o - Is anyone using ???sqlite3_blob_write????

2010-01-19 Thread Jay A. Kreibich
On Tue, Jan 19, 2010 at 08:52:17AM -0800, a1rex scratched on the wall:
> Thank you very much for your response! I appreciate you input.
> 
> >  Incremental BLOB I/O handles depend on an internal statement.
> 
> Sorry, which statement is involved?

  The one inside the sqlite3_blob handle.

  Look at the source for sqlite3_blob_open().

   -j

-- 
Jay A. Kreibich < J A Y  @  K R E I B I.C H >

"Our opponent is an alien starship packed with atomic bombs.  We have
 a protractor."   "I'll go home and see if I can scrounge up a ruler
 and a piece of string."  --from Anathem by Neal Stephenson
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Incremental i/o - Is anyone using ???sqlite3_blob_write????

2010-01-19 Thread a1rex
Thank you very much for your response! I
appreciate you input.

>  Incremental BLOB I/O handles depend on an internal statement.

Sorry, which statement is involved?

 
int sqlite3_blob_open(
  sqlite3*,
  const char *zDb,
  const char *zTable,
  const char
*zColumn,
  sqlite3_int64 iRow,
  int flags,
  sqlite3_blob
**ppBlob
);does not have a statement.  To get 'ppBlob' we have to specify only  iRow.


>  I'd turn on tracing so that you have an exact record of all the
>  statements that are executed.

 
I do not do any DROPS, CREATS nothing.
 My table ‘A’ has a BLOB.  What I do is only 1 UPDATE in the table ‘B’. I 
verified using
sqlite3_total_changes(sqlite3*) – that only 1 changed happened – change to the
row in the table ‘B’ . Yet, to my surprise the handle to the BLOB in the table 
‘A’
got invalidated! 

 
I do not do any DROPS, CREATS nothing special at all!

 
My table ‘A’ has a BLOB.  What I do is 1 UPDATE in the table ‘B’. I verified 
using
sqlite3_total_changes(sqlite3*) – that only 1 changed happened – change to the
row in the table ‘B’ . Yet, to my surprise the handle to the BLOB in the table
‘A’ got invalidated!
 
(All what I do in my code is as follows:
In a loop, I find  iRow for my blob in the table ‘A’,  open blob in the iRow. 
Than I update table
‘B’ with some information from table ‘A’.  Than I  blob_write to the blob in
the table A. This write fails frequently with code SQLITE_ABORT. I do not see 
any reason why it fails!)

Thank you again for your comments.

Best Regards,
Samuel





From: Jay A. Kreibich 
To: General Discussion of SQLite Database 
Sent: Tue, January 19, 2010 11:00:54 AM
Subject: Re: [sqlite] Incremental i/o - Is anyone using 
???sqlite3_blob_write

On Tue, Jan 19, 2010 at 07:14:11AM -0800, a1rex scratched on the wall:


> So, I coded accordingly.  I thought that I could keep the same handle to the 
> blob forever as long
> as I do not touch the row where my blob is located. At least that is my
> understanding of the documentation. 
>  
> Soon, I discovered that after some updates to other table my
> blob handle is no longer valid.  The
> problem was not consistent; some updates would invalidate the handle some 
> would
> not.  

  Incremental BLOB I/O handles depend on an internal statement.  As I
  understand it, any operation that invalidates statements will also
  invalidate all the current BLOB handles.  For example, I'm fairly
  sure changing the schema (any CREATE..., DROP..., etc.) will
  invalidate all BLOB I/O handles.  I haven't verified this, but my
  (small) understanding of the code makes me believe this is true.

  As you're aware, there are other reasons a handle can become invalid.

  I'd turn on tracing so that you have an exact record of all the
  statements that are executed.  When you hit a handle error, start
  looking through the trace log to see what might be causing it.

   -j

-- 
Jay A. Kreibich < J A Y  @  K R E I B I.C H >

"Our opponent is an alien starship packed with atomic bombs.  We have
a protractor."   "I'll go home and see if I can scrounge up a ruler
and a piece of string."  --from Anathem by Neal Stephenson
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users



  __
Ask a question on any topic and get answers from real people. Go to Yahoo! 
Answers and share what you know at http://ca.answers.yahoo.com
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Incremental i/o - Is anyone using ???sqlite3_blob_write????

2010-01-19 Thread Jay A. Kreibich
On Tue, Jan 19, 2010 at 07:14:11AM -0800, a1rex scratched on the wall:

 
> So, I coded accordingly.  I thought that I could keep the same handle to the 
> blob forever as long
> as I do not touch the row where my blob is located. At least that is my
> understanding of the documentation. 
>  
> Soon, I discovered that after some updates to other table my
> blob handle is no longer valid.  The
> problem was not consistent; some updates would invalidate the handle some 
> would
> not.  

  Incremental BLOB I/O handles depend on an internal statement.  As I
  understand it, any operation that invalidates statements will also
  invalidate all the current BLOB handles.  For example, I'm fairly
  sure changing the schema (any CREATE..., DROP..., etc.) will
  invalidate all BLOB I/O handles.  I haven't verified this, but my
  (small) understanding of the code makes me believe this is true.

  As you're aware, there are other reasons a handle can become invalid.

  I'd turn on tracing so that you have an exact record of all the
  statements that are executed.  When you hit a handle error, start
  looking through the trace log to see what might be causing it.

   -j

-- 
Jay A. Kreibich < J A Y  @  K R E I B I.C H >

"Our opponent is an alien starship packed with atomic bombs.  We have
 a protractor."   "I'll go home and see if I can scrounge up a ruler
 and a piece of string."  --from Anathem by Neal Stephenson
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Need help understanding the basic of C++/sqlite

2010-01-19 Thread Simon Davies
2010/1/19 Fabrice NA :
> Hi all,
>
> I am trying to understand Sqlite and to make thing worse I am also learning
> C++. You will not be surprised that I find it really hard to understand the
> C++ example on the web. Can someone guide me to digest this? If you can
> explain please do so by extrapolating since I am a total newbie.
>
> I have managed to compile the code example into a file called testdb.exe and
> have created a database named Cars.db containing 7 rows. (notice that I have
> removed some part of that code that I don't need help for)
>
> #include 
> #include 
>
> static int callback(void *NotUsed, int argc, char **argv, char **azColName){
>  int i;
>  for(i=0; i    printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
>  }
>  printf("\n");
>  return 0;
> }
>
> int main(int argc, char **argv){
>  sqlite3 *db;
>  char *zErrMsg = 0;
>  int rc;
>  if( argc!=3 ){
>    fprintf(stderr, "Usage: %s DATABASE SQL-STATEMENT\n", argv[0]);
>    exit(1);
>  }
>
>  rc = sqlite3_open(argv[1], &db);
>  rc = sqlite3_exec(db, argv[2], callback, 0, &zErrMsg);
>
>  sqlite3_close(db);
>
>  return 0;
>
> }
>
> Now in command line when I execute testdb.exe cars.db "select * from cars"
> (the table is called cars too) everything works fine and I get an output
> with all my seven rows. But how come this work? Is this some kind of magic?

No

>
> Even after reading the doc again and again I don't understand (probably
> because I am still learning some basic C++ concepts). Here my questions;

Your problems appear to be mostly understanding C/C++.

>
> 1)       What is the purpose of doing "sqlite3  *db"  are we just creating a
> pointer of type sqlite3 named db here?

Yes. It is essentially a handle to the database that is returned by
the database open call, which then needs to be passed to other sqlite
library routines.

>
> 2)       At first I though that for the main function the first
> parameter  "cars.db"
> was represented by the variable argc and the second "select * from cars" by
> argv. Well at the end, it looks like that "cars.db" is argv[1] and that the
> select statement is argv[2]. What is argc then?

argc is the count of passed in arguments
argv is the vector of passed in arguments
argv[0] is always the name of the executable that is executing

> Seems like it's the number
> of rows returned by the query (when looking at function callback) but how
> the program find this out? How come we have a line "  if( argc!=3 )" and see
> this same argc variable in the callback function?

argc/argv in main and argc/argv in callback have nothing to do with each other.

callback is a routine that needs to be provided for an sqlite_exec()
call. In callback argc would be better named numColumns, and argv
better named columnData.

>
> 3)       I don't understand the third argument from the query " rc =
> sqlite3_exec(db, argv[2], callback, 0, &zErrMsg);" my problem is
> understanding the callback function inside the sqlite3_exec function.
> Reading this link http://www.sqlite.org/c3ref/exec.html didn't help too much
> even though it has been written in plain English.

As sqlite_exec() retrieves each row of data, it calls the callback
routine that is provided via the third argument (in your case also
named 'callback'). You can then do what YOU want with the data by
coding the callback appropriately. In the case you have shown, the
values are simply being printed out.

>
> 4)       I am using VC++ Express from Microsoft  on WinXP and would like to
> know if it's possible to pass parameter when debugging i.e. tell the
> debugger to use cars.db for file and use "select * from cars" as a statement
> (this would allow me to see what's hapening witout replacing variables by
> their real values).

Don't know about VC++ Express, but in Visual Studio there is a
debugging tab on the project properties page that allows command line
arguments to be specified.

>
> 5)       It's really hard to find some simple example on internet about C++
> working with sqlite. Can any of you provide with simple sample codes that
> shows how you can do and what you can do with sqlite and C++?

SQLite is a C library, not C++. You can however link C++ code against
C object, and the SQLite library even provides appropriate 'extern "C"
{}' wrapping around things so that it can be compiled with a C++
compiler; but that does not make it C++ code.

There are C++ wrappers, notably System.Data.SQLite
(http://sqlite.phxsoftware.com)
(sorry anybody else)

further things to take a look at:
http://www.sqlite.org/cintro.html

The code you show above is based on sqlite3_exec(). This is
deprecated; better to use sqlite3_prepare_v2(), sqlite3_step,
sqlite3_reset()/sqlite3_finalize():
http://www.sqlite.org/cvstrac/wiki?p=SimpleCode

>
> I hope I didn't offended anyone with my lack of knowledge and I thank in
> advance the courageous ones who managed to read this email until the end and
> probably got answers to my questions.
>
> Fabou

Regards,
Simon

Re: [sqlite] Need help understanding the basic of C++/sqlite

2010-01-19 Thread a1rex
1. Complete c program for beginners  is here:

http://manishtech.wordpress.com/2009/03/30/sqlite-with-c/


2. sqlite3_exec with callback is an obsolete concept from sqlite2

Use sqlite3_prepare_v2 with sqlite3_step  as it is linear,  more effective and 
giving more control approach.
 
I hope it helps,
Samuel




From: noel frankinet 
To: General Discussion of SQLite Database 
Sent: Tue, January 19, 2010 9:18:06 AM
Subject: Re: [sqlite] Need help understanding the basic of C++/sqlite

Fabrice NA a écrit :

Hi,

In sqlite3_exec, you pass a function pointer (callback).
Sqlite call that function with each row of data

Best wishes

Noël
> Hi all,
>
>
>
> I am trying to understand Sqlite and to make thing worse I am also learning
> C++. You will not be surprised that I find it really hard to understand the
> C++ example on the web. Can someone guide me to digest this? If you can
> explain please do so by extrapolating since I am a total newbie.
>
>
>
> I have managed to compile the code example into a file called testdb.exe and
> have created a database named Cars.db containing 7 rows. (notice that I have
> removed some part of that code that I don't need help for)
>
>
>
> #include 
>
> #include 
>
>
>
> static int callback(void *NotUsed, int argc, char **argv, char **azColName){
>
>   int i;
>
>   for(i=0; i
> printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
>
>   }
>
>   printf("\n");
>
>   return 0;
>
> }
>
>
>
> int main(int argc, char **argv){
>
>   sqlite3 *db;
>
>   char *zErrMsg = 0;
>
>   int rc;
>
>
>
>   if( argc!=3 ){
>
> fprintf(stderr, "Usage: %s DATABASE SQL-STATEMENT\n", argv[0]);
>
> exit(1);
>
>   }
>
>   rc = sqlite3_open(argv[1], &db);
>
>
>
>   rc = sqlite3_exec(db, argv[2], callback, 0, &zErrMsg);
>
>
>
>   sqlite3_close(db);
>
>
>
>   return 0;
>
> }
>
>
>
> Now in command line when I execute testdb.exe cars.db "select * from cars"
> (the table is called cars too) everything works fine and I get an output
> with all my seven rows. But how come this work? Is this some kind of magic?
>
>
>
> Even after reading the doc again and again I don't understand (probably
> because I am still learning some basic C++ concepts). Here my questions;
>
>
>
> 1)   What is the purpose of doing "sqlite3  *db"  are we just creating a
> pointer of type sqlite3 named db here?
>
>
>
> 2)   At first I though that for the main function the first
> parameter  "cars.db"
> was represented by the variable argc and the second "select * from cars" by
> argv. Well at the end, it looks like that "cars.db" is argv[1] and that the
> select statement is argv[2]. What is argc then?  Seems like it's the number
> of rows returned by the query (when looking at function callback) but how
> the program find this out? How come we have a line "  if( argc!=3 )" and see
> this same argc variable in the callback function?
>
>
>
> 3)   I don't understand the third argument from the query " rc =
> sqlite3_exec(db, argv[2], callback, 0, &zErrMsg);" my problem is
> understanding the callback function inside the sqlite3_exec function.
> Reading this link http://www.sqlite.org/c3ref/exec.html didn't help too much
> even though it has been written in plain English.
>
>
>
> 4)   I am using VC++ Express from Microsoft  on WinXP and would like to
> know if it's possible to pass parameter when debugging i.e. tell the
> debugger to use cars.db for file and use "select * from cars" as a statement
> (this would allow me to see what's hapening witout replacing variables by
> their real values).
>
>
>
> 5)   It's really hard to find some simple example on internet about C++
> working with sqlite. Can any of you provide with simple sample codes that
> shows how you can do and what you can do with sqlite and C++?
>
>
>
> I hope I didn't offended anyone with my lack of knowledge and I thank in
> advance the courageous ones who managed to read this email until the end and
> probably got answers to my questions.
>
>
>
> Fabou
> ___
> 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



  __
Looking for the perfect gift? Give the gift of Flickr! 

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


[sqlite] Incremental i/o - Is anyone using ‘sq lite3_blob_write’?

2010-01-19 Thread a1rex

I have to admit my confusion with incremental i/o functions.
 
I am not sure that problem, which I encountered, is due to
internal bug in my program, I hit a Sqlite bug or Sqlite behaves properly. I
would greatly appreciate any comments! 
 
First, the incremental i/o looked as a God’s sent gift to me.
Being able to just read or write a portion of the blob looked like a huge time
saving and great advantage over the traditional approach.
 
So, I coded accordingly.  I thought that I could keep the same handle to the 
blob forever as long
as I do not touch the row where my blob is located. At least that is my
understanding of the documentation. 
 
Soon, I discovered that after some updates to other table my
blob handle is no longer valid.  The
problem was not consistent; some updates would invalidate the handle some would
not.  
 
My solution to the problem seems (to me) a crude one. Before
any update I close all blob handles do an update on reopen the blobs. 

 
If anyone using incremental i/o could confirm that this
is general practice I would be thankful! 

 
Thank you kindly,
Samuel
 (Since I can split my blob in parts and do a 'traditional' update only
to the required part the need to frequently close and open  blobs seems
like an overhead.) 


  __
Looking for the perfect gift? Give the gift of Flickr! 

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


Re: [sqlite] Need help understanding the basic of C++/sqlite

2010-01-19 Thread noel frankinet
Fabrice NA a écrit :

Hi,

In sqlite3_exec, you pass a function pointer (callback).
Sqlite call that function with each row of data

Best wishes

Noël
> Hi all,
>
>
>
> I am trying to understand Sqlite and to make thing worse I am also learning
> C++. You will not be surprised that I find it really hard to understand the
> C++ example on the web. Can someone guide me to digest this? If you can
> explain please do so by extrapolating since I am a total newbie.
>
>
>
> I have managed to compile the code example into a file called testdb.exe and
> have created a database named Cars.db containing 7 rows. (notice that I have
> removed some part of that code that I don't need help for)
>
>
>
> #include 
>
> #include 
>
>
>
> static int callback(void *NotUsed, int argc, char **argv, char **azColName){
>
>   int i;
>
>   for(i=0; i
> printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : "NULL");
>
>   }
>
>   printf("\n");
>
>   return 0;
>
> }
>
>
>
> int main(int argc, char **argv){
>
>   sqlite3 *db;
>
>   char *zErrMsg = 0;
>
>   int rc;
>
>
>
>   if( argc!=3 ){
>
> fprintf(stderr, "Usage: %s DATABASE SQL-STATEMENT\n", argv[0]);
>
> exit(1);
>
>   }
>
>   rc = sqlite3_open(argv[1], &db);
>
>
>
>   rc = sqlite3_exec(db, argv[2], callback, 0, &zErrMsg);
>
>
>
>   sqlite3_close(db);
>
>
>
>   return 0;
>
> }
>
>
>
> Now in command line when I execute testdb.exe cars.db "select * from cars"
> (the table is called cars too) everything works fine and I get an output
> with all my seven rows. But how come this work? Is this some kind of magic?
>
>
>
> Even after reading the doc again and again I don't understand (probably
> because I am still learning some basic C++ concepts). Here my questions;
>
>
>
> 1)   What is the purpose of doing "sqlite3  *db"  are we just creating a
> pointer of type sqlite3 named db here?
>
>
>
> 2)   At first I though that for the main function the first
> parameter  "cars.db"
> was represented by the variable argc and the second "select * from cars" by
> argv. Well at the end, it looks like that "cars.db" is argv[1] and that the
> select statement is argv[2]. What is argc then?  Seems like it's the number
> of rows returned by the query (when looking at function callback) but how
> the program find this out? How come we have a line "  if( argc!=3 )" and see
> this same argc variable in the callback function?
>
>
>
> 3)   I don't understand the third argument from the query " rc =
> sqlite3_exec(db, argv[2], callback, 0, &zErrMsg);" my problem is
> understanding the callback function inside the sqlite3_exec function.
> Reading this link http://www.sqlite.org/c3ref/exec.html didn't help too much
> even though it has been written in plain English.
>
>
>
> 4)   I am using VC++ Express from Microsoft  on WinXP and would like to
> know if it's possible to pass parameter when debugging i.e. tell the
> debugger to use cars.db for file and use "select * from cars" as a statement
> (this would allow me to see what's hapening witout replacing variables by
> their real values).
>
>
>
> 5)   It's really hard to find some simple example on internet about C++
> working with sqlite. Can any of you provide with simple sample codes that
> shows how you can do and what you can do with sqlite and C++?
>
>
>
> I hope I didn't offended anyone with my lack of knowledge and I thank in
> advance the courageous ones who managed to read this email until the end and
> probably got answers to my questions.
>
>
>
> Fabou
> ___
> 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


[sqlite] Need help understanding the basic of C++/sqlite

2010-01-19 Thread Fabrice NA
Hi all,



I am trying to understand Sqlite and to make thing worse I am also learning
C++. You will not be surprised that I find it really hard to understand the
C++ example on the web. Can someone guide me to digest this? If you can
explain please do so by extrapolating since I am a total newbie.



I have managed to compile the code example into a file called testdb.exe and
have created a database named Cars.db containing 7 rows. (notice that I have
removed some part of that code that I don't need help for)



#include 

#include 



static int callback(void *NotUsed, int argc, char **argv, char **azColName){

  int i;

  for(i=0; ihttp://www.sqlite.org/c3ref/exec.html didn't help too much
even though it has been written in plain English.



4)   I am using VC++ Express from Microsoft  on WinXP and would like to
know if it's possible to pass parameter when debugging i.e. tell the
debugger to use cars.db for file and use "select * from cars" as a statement
(this would allow me to see what's hapening witout replacing variables by
their real values).



5)   It's really hard to find some simple example on internet about C++
working with sqlite. Can any of you provide with simple sample codes that
shows how you can do and what you can do with sqlite and C++?



I hope I didn't offended anyone with my lack of knowledge and I thank in
advance the courageous ones who managed to read this email until the end and
probably got answers to my questions.



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


Re: [sqlite] load_extension() and extension-functions .c

2010-01-19 Thread Oliver Peters
Liam Healy  writes:

[...]
> 
> >
> >
> > s2: extension-functions.c
> > -
> > add compilation instructions for windows
> 
> I don't know how to compile in windows; if you or
> someone has some instructions, I'll add them.


compile instructions for Windows:


1. Install MinGW (http://www.mingw.org/) and you will get the gcc (gnu compiler
collection)

2. add the path to your path variable (isn't done during the installation!)

3. compile this way:

gcc -shared -I "path" -o libsqlitefunctions.so extension-functions.c

(path = path of sqlite3ext.h; i.e. C:\programs\sqlite)


greetings
Oliver


[...]




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


Re: [sqlite] bug in proxyGetHostID()

2010-01-19 Thread Jens Miltner

Am 16.01.2010 um 19:00 schrieb Thomas Stüfe:

> Greetings,
>
> I think I found a small bug in sqlite 3.6.22 in the function  
> proxyGetHostID().
>
> There, pread() and pwrite() are used to read a host id file. Return  
> value of these functions is assigned to a size_t variable. size_t is  
> unsigned. Should pread fail for any reason (IO Error or whatever)  
> and return -1, the error handling would not kick in. Instead, the  
> function would probably just leave the host id uninitialized and  
> return ok.
>
> A valid fix might be using ssize_t (signed size_t) instead of  
> size_t, but I cannot of course say whether this would work on all  
> platforms.

AFAICS, this is for Mac OS X only anyway...
pread returns an ssize_t according to the docs, so the proposed change  
looks safe to me...

Another potential problem is when for some reason the hostid file is  
empty: in this case pread will return 0, which will leave pHostID  
uninitialized, too.
It will return a result code, but the OSTRACE3 inside proxyGetHostID  
still attempts to dump the host ID, which at this point will be  
uninitialized.


>
> My Platform is MacOS X, I compile with gcc 4.2. I compile the  
> amalgamation for sqlite 3.6.22. I only found this because gcc warns:
>
> sqlite3.c:26120: warning: comparison of unsigned expression < 0 is  
> always false
> sqlite3.c:26134: warning: comparison of unsigned expression < 0 is  
> always false




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