Re: [sqlite] Extremely new to SQLite

2007-08-08 Thread John Stanton
The callback interface is there to support legacy applications.  It has 
been replaced by prepare/step for new work.


Lee Crain wrote:

Dennis,

Are you certain that the callback function interface has been deprecated? 


From the link you posted:


---

"2.2 Executing SQL statements
   typedef int (*sqlite_callback)(void*,int,char**, char**);
   int sqlite3_exec(sqlite3*, const char *sql, sqlite_callback, void*,
char**);
The sqlite3_exec function works much as it did in SQLite version 2. Zero
or more SQL statements specified in the second parameter are compiled and
executed. Query results are returned to a callback routine."

---

I couldn't find a reference to its deprecation.

Lee Crain




-Original Message-
From: Dennis Cote [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 07, 2007 1:08 PM

To: sqlite-users@sqlite.org
Subject: Re: [sqlite] Extremely new to SQLite

Stephen Sutherland wrote:

use the quick start code 
 http://www.sqlite.org/quickstart.html
  
 That's what I used to build all my code from  
  
 


Stephen,

The quickstart code is very old. It uses the callback function interface 
which is a depreciated API function that is maintained primarily for 
backward compatibility.


You should really look at the prepare/bind/step/column set of API 
functions introduced in version 3 which is described at 
http://www.sqlite.org/capi3.html


Dennis Cote

--
---
To unsubscribe, send email to [EMAIL PROTECTED]
--
---



-
To unsubscribe, send email to [EMAIL PROTECTED]
-




-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Extremely new to SQLite

2007-08-07 Thread drh
"Lee Crain" <[EMAIL PROTECTED]> wrote:
> Thanks for a detailed response, Dennis. 
> 
> Under some time constraints, I just finished an important implementation
> and used the callback function as the means of acquiring returned data. 
> 
> I don't want that interface to become obsolete any time soon. Maybe I need
> to consider migrating to the newer, preferred interface.
> 

SQLite uses sqlite3_exec() internally (when it is loading the
schema out of the sqlite_master table) so it is unlikely to
go away anytime soon.

--
D. Richard Hipp <[EMAIL PROTECTED]>


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



RE: [sqlite] Extremely new to SQLite

2007-08-07 Thread Lee Crain
Thanks for a detailed response, Dennis. 

Under some time constraints, I just finished an important implementation
and used the callback function as the means of acquiring returned data. 

I don't want that interface to become obsolete any time soon. Maybe I need
to consider migrating to the newer, preferred interface.

Lee




-Original Message-
From: Dennis Cote [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 07, 2007 5:08 PM
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] Extremely new to SQLite

Lee Crain wrote:
> Dennis,
>
> Are you certain that the callback function interface has been
deprecated? 
>
> >From the link you posted:
>
> ---
>
> "2.2 Executing SQL statements
>typedef int (*sqlite_callback)(void*,int,char**, char**);
>int sqlite3_exec(sqlite3*, const char *sql, sqlite_callback, void*,
> char**);
> The sqlite3_exec function works much as it did in SQLite version 2. Zero
> or more SQL statements specified in the second parameter are compiled
and
> executed. Query results are returned to a callback routine."
>
> ---
>
> I couldn't find a reference to its deprecation.
>
>   
Lee,

Perhaps depreciated may be too strong, but it is no longer recommended. 
If you continue reading in the section you quoted you will find the 
following:

> In SQLite version 3, the sqlite3_exec routine is just a wrapper around 
> calls to the prepared statement interface.
>
>typedef struct sqlite3_stmt sqlite3_stmt;
>int sqlite3_prepare
<http://www.sqlite.org/capi3ref.html#sqlite3_prepare>(sqlite3*, const
char*, int, sqlite3_stmt**, const char**);
>int sqlite3_prepare16
<http://www.sqlite.org/capi3ref.html#sqlite3_prepare16>(sqlite3*, const
void*, int, sqlite3_stmt**, const void**);
>int sqlite3_finalize
<http://www.sqlite.org/capi3ref.html#sqlite3_finalize>(sqlite3_stmt*);
>int sqlite3_reset
<http://www.sqlite.org/capi3ref.html#sqlite3_reset>(sqlite3_stmt*);
> 
>
> The sqlite3_prepare interface compiles a single SQL statement into 
> byte code for later execution. This interface is now the preferred way 
> of accessing the database.
>
The last sentence is the basis for my claim.

I still use sqlite3_exec all the time, but only to execute statements 
that don't return a result set. Hence, I think it is really the callback 
mechanism that has been depreciated, not sqlite3_exec itself.

The callback mechanism is still supported for backwards compatibility, 
which is why the quickstart code (along with lots of other existing 
sqlite client code) still works, but it should not be used for new code.

HTH
Dennis Cote

--
---
To unsubscribe, send email to [EMAIL PROTECTED]
--
---



-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Extremely new to SQLite

2007-08-07 Thread Dennis Cote

P Kishor wrote:


In which case, "deprecated" is definitely too strong, but
"depreciated" might well be apt.

;-)


  

Good catch. I missed that all together.

Lee may have been using the word in the sense that the American Heritage 
Dictionary says is now common enough to list the milder term as a 
meaning of the stronger term.


*/Usage Note: /* The first and fully accepted meaning of /deprecate/ is 
"to express disapproval of." But the word has steadily encroached on the 
meaning of /depreciate./ It is now used, almost to the exclusion of 
/depreciate,/ in the sense "to belittle or mildly disparage," as in /He 
deprecated his own contribution./ In an earlier survey, this newer sense 
was approved by a majority of the Usage Panel.


Dennis Cote



-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Extremely new to SQLite

2007-08-07 Thread P Kishor
On 8/7/07, Dennis Cote <[EMAIL PROTECTED]> wrote:
> Lee Crain wrote:
> > Dennis,
> >
> > Are you certain that the callback function interface has been deprecated?
> >
> > >From the link you posted:
> >
> > ---
> >
> > "2.2 Executing SQL statements
> >typedef int (*sqlite_callback)(void*,int,char**, char**);
> >int sqlite3_exec(sqlite3*, const char *sql, sqlite_callback, void*,
> > char**);
> > The sqlite3_exec function works much as it did in SQLite version 2. Zero
> > or more SQL statements specified in the second parameter are compiled and
> > executed. Query results are returned to a callback routine."
> >
> > ---
> >
> > I couldn't find a reference to its deprecation.
> >
> >
> Lee,
>
> Perhaps depreciated may be too strong, but it is no longer recommended.

In which case, "deprecated" is definitely too strong, but
"depreciated" might well be apt.

;-)

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Extremely new to SQLite

2007-08-07 Thread Dennis Cote

Lee Crain wrote:

Dennis,

Are you certain that the callback function interface has been deprecated? 


>From the link you posted:

---

"2.2 Executing SQL statements
   typedef int (*sqlite_callback)(void*,int,char**, char**);
   int sqlite3_exec(sqlite3*, const char *sql, sqlite_callback, void*,
char**);
The sqlite3_exec function works much as it did in SQLite version 2. Zero
or more SQL statements specified in the second parameter are compiled and
executed. Query results are returned to a callback routine."

---

I couldn't find a reference to its deprecation.

  

Lee,

Perhaps depreciated may be too strong, but it is no longer recommended. 
If you continue reading in the section you quoted you will find the 
following:


In SQLite version 3, the sqlite3_exec routine is just a wrapper around 
calls to the prepared statement interface.


   typedef struct sqlite3_stmt sqlite3_stmt;
   int sqlite3_prepare 
(sqlite3*, const char*, 
int, sqlite3_stmt**, const char**);
   int sqlite3_prepare16 
(sqlite3*, const void*, 
int, sqlite3_stmt**, const void**);
   int sqlite3_finalize 
(sqlite3_stmt*);
   int sqlite3_reset 
(sqlite3_stmt*);


The sqlite3_prepare interface compiles a single SQL statement into 
byte code for later execution. This interface is now the preferred way 
of accessing the database.



The last sentence is the basis for my claim.

I still use sqlite3_exec all the time, but only to execute statements 
that don't return a result set. Hence, I think it is really the callback 
mechanism that has been depreciated, not sqlite3_exec itself.


The callback mechanism is still supported for backwards compatibility, 
which is why the quickstart code (along with lots of other existing 
sqlite client code) still works, but it should not be used for new code.


HTH
Dennis Cote

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



RE: [sqlite] Extremely new to SQLite

2007-08-07 Thread Lee Crain
Dennis,

Are you certain that the callback function interface has been deprecated? 

>From the link you posted:

---

"2.2 Executing SQL statements
   typedef int (*sqlite_callback)(void*,int,char**, char**);
   int sqlite3_exec(sqlite3*, const char *sql, sqlite_callback, void*,
char**);
The sqlite3_exec function works much as it did in SQLite version 2. Zero
or more SQL statements specified in the second parameter are compiled and
executed. Query results are returned to a callback routine."

---

I couldn't find a reference to its deprecation.

Lee Crain




-Original Message-
From: Dennis Cote [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 07, 2007 1:08 PM
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] Extremely new to SQLite

Stephen Sutherland wrote:
> use the quick start code 
>   http://www.sqlite.org/quickstart.html
>
>   That's what I used to build all my code from  
>
>   
Stephen,

The quickstart code is very old. It uses the callback function interface 
which is a depreciated API function that is maintained primarily for 
backward compatibility.

You should really look at the prepare/bind/step/column set of API 
functions introduced in version 3 which is described at 
http://www.sqlite.org/capi3.html

Dennis Cote

--
---
To unsubscribe, send email to [EMAIL PROTECTED]
--
---



-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Extremely new to SQLite

2007-08-07 Thread Dennis Cote

Stephen Sutherland wrote:
use the quick start code 
  http://www.sqlite.org/quickstart.html
   
  That's what I used to build all my code from  
   
  

Stephen,

The quickstart code is very old. It uses the callback function interface 
which is a depreciated API function that is maintained primarily for 
backward compatibility.


You should really look at the prepare/bind/step/column set of API 
functions introduced in version 3 which is described at 
http://www.sqlite.org/capi3.html


Dennis Cote

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Extremely new to SQLite

2007-08-07 Thread Stephen Sutherland
use the quick start code 
  http://www.sqlite.org/quickstart.html
   
  That's what I used to build all my code from  
   
  Stephen 
  

Dennis Cote <[EMAIL PROTECTED]> wrote:
  Rahul Banerjee wrote:
> I'm trying to integrate SQLite into a library management system coded 
> in C++. I'm extremely new to SQLite and the documentation at 
> http://www.sqlite.org didn't do it for me.
> Can anyone give me some help/tips.
> All I need to do is:
> 1. Access db
> 2. Retrieve data from a particular row and column (and store it into a 
> var)
> 3. Write/Modify data into db
> 4. Save and exit db
>
> Any help is greatly appreciated!
>
>
Rahul,

This link http://www.codeproject.com/database/CppSQLite.asp will take 
you to a site that has a good C++ wrapper for SQLite and some good 
sample code that shows how to use the wrapper to do the things you need 
to do. The CppSQLite wrapper library is available to download from the 
site as well.

HTH
Dennis Cote

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



   
-
Need a vacation? Get great deals to amazing places on Yahoo! Travel. 

Re: [sqlite] Extremely new to SQLite

2007-08-07 Thread Dennis Cote

Rahul Banerjee wrote:
I'm trying to integrate SQLite into a library management system coded 
in C++. I'm extremely new to SQLite and the documentation at 
http://www.sqlite.org didn't do it for me.

Can anyone give me some help/tips.
All I need to do is:
1. Access db
2. Retrieve data from a particular row and column (and store it into a 
var)

3. Write/Modify data into db
4. Save and exit db

Any help is greatly appreciated!



Rahul,

This link http://www.codeproject.com/database/CppSQLite.asp will take 
you to a site that has a good C++ wrapper for SQLite and some good 
sample code that shows how to use the wrapper to do the things you need 
to do. The CppSQLite wrapper library is available to download from the 
site as well.


HTH
Dennis Cote

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Extremely new to SQLite

2007-07-30 Thread Rahul Banerjee

Thanks James,
But everything is still foggy to me. Could you show me some example 
syntax that accomplishes the following.

Thanks again,
Rahul.

James Dennett wrote:
  

-Original Message-
From: Rahul Banerjee [mailto:[EMAIL PROTECTED]
Sent: Friday, July 27, 2007 1:34 PM
To: sqlite-users@sqlite.org
Subject: [sqlite] Extremely new to SQLite

Hi,
I'm trying to integrate SQLite into a library management system coded


in
  

C++. I'm extremely new to SQLite and the documentation at
http://www.sqlite.org didn't do it for me.
Can anyone give me some help/tips.
All I need to do is:
1. Access db



See the docs on sqlite3_open() for getting a handle to a database.

  

2. Retrieve data from a particular row and column (and store it into a
var)



I'd recommend using sqlite3_prepare_v2 to prepare the statement, the
various sqlite3_bind_*() functions to bind variables, and then
sqlite3_step() to execute it.  You'll prepare something lke "select col1
from table2 where col2=:1" (or one of various placeholder syntaxes
supported by SQLite3).  Obviously you'll need some understanding of SQL
in general, which is largely not specific to SQLite.

  

3. Write/Modify data into db



Pretty much the same as selecting data, but with different SQL.

  

4. Save and exit db



You don't "save"; you "commit;" your transaction, if you started one.
If you didn't start one explicitly, there's nothing to do; the library
will commit after each statement.  That's the joy of Durability in ACID.

-- James


-
To unsubscribe, send email to [EMAIL PROTECTED]
-


  



-
To unsubscribe, send email to [EMAIL PROTECTED]
-



RE: [sqlite] Extremely new to SQLite

2007-07-27 Thread James Dennett


> -Original Message-
> From: Rahul Banerjee [mailto:[EMAIL PROTECTED]
> Sent: Friday, July 27, 2007 1:34 PM
> To: sqlite-users@sqlite.org
> Subject: [sqlite] Extremely new to SQLite
> 
> Hi,
> I'm trying to integrate SQLite into a library management system coded
in
> C++. I'm extremely new to SQLite and the documentation at
> http://www.sqlite.org didn't do it for me.
> Can anyone give me some help/tips.
> All I need to do is:
> 1. Access db

See the docs on sqlite3_open() for getting a handle to a database.

> 2. Retrieve data from a particular row and column (and store it into a
> var)

I'd recommend using sqlite3_prepare_v2 to prepare the statement, the
various sqlite3_bind_*() functions to bind variables, and then
sqlite3_step() to execute it.  You'll prepare something lke "select col1
from table2 where col2=:1" (or one of various placeholder syntaxes
supported by SQLite3).  Obviously you'll need some understanding of SQL
in general, which is largely not specific to SQLite.

> 3. Write/Modify data into db

Pretty much the same as selecting data, but with different SQL.

> 4. Save and exit db

You don't "save"; you "commit;" your transaction, if you started one.
If you didn't start one explicitly, there's nothing to do; the library
will commit after each statement.  That's the joy of Durability in ACID.

-- James


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



[sqlite] Extremely new to SQLite

2007-07-27 Thread Rahul Banerjee

Hi,
I'm trying to integrate SQLite into a library management system coded in 
C++. I'm extremely new to SQLite and the documentation at 
http://www.sqlite.org didn't do it for me.

Can anyone give me some help/tips.
All I need to do is:
1. Access db
2. Retrieve data from a particular row and column (and store it into a var)
3. Write/Modify data into db
4. Save and exit db

Any help is greatly appreciated!
Thanks,
Rahul.

-
To unsubscribe, send email to [EMAIL PROTECTED]
-