Re: [sqlite] SQLite and C++

2012-06-13 Thread PJ Naughter
I've just released a set of C++ wrapper classes at
http://www.naughter.com/sqlitewrappers.html if you want to check them out.

Regards,
PJ Naughter [Visual C++ MVP]

Naughter Software Ltd
Mail: pjna at naughter.com
Web: www.naughter.com
Hotmail/MSN Messenger: pjnaughter at hotmail.com

-Original Message-
From: sqlite-users-boun...@sqlite.org
[mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Arbol One
Sent: 13 June 2012 12:22
To: SQLite user list Users
Subject: [sqlite] SQLite and C++

Anyone knows where I can find some examples of how C++ interfaces with
SQLite? I just need to see some code that is functional and not just some
snips of how it maybe-should-possibly work.
 TIA
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

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


Re: [sqlite] SQLite and C++

2012-06-13 Thread Simon Slavin

On 13 Jun 2012, at 12:21pm, "Arbol One"  wrote:

> Anyone knows where I can find some examples of how C++ interfaces with 
> SQLite? I just need to see some code that is functional and not just some 
> snips of how it maybe-should-possibly work.

The code at the bottom of this page works, and does include all the 
error-trapping that should be done:



It's C and doesn't use any C++ features, but that is how you use the C/C++ API.

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


Re: [sqlite] SQLite and C++

2012-06-13 Thread John Drescher
On Wed, Jun 13, 2012 at 7:21 AM, Arbol One  wrote:
> Anyone knows where I can find some examples of how C++ interfaces with 
> SQLite? I just need to see some code that is functional and not just some 
> snips of how it maybe-should-possibly work.


Although this is probably not what you want Qt comes with a bundled
sqlite that it uses with its C++ database classes.

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


Re: [sqlite] SQLite and C++

2012-06-13 Thread Stephan Beal
On Wed, Jun 13, 2012 at 1:21 PM, Arbol One  wrote:

> Anyone knows where I can find some examples of how C++ interfaces with
> SQLite? I just need to see some code that is functional and not just some
> snips of how it maybe-should-possibly work.
>

Here's mine:

http://fossil.wanderinghorse.net/repos/sqlite-stuff/ (3 different C++
wrappers)
http://fossil.wanderinghorse.net/wikis/cpdo/?page=cpdopp (generic,
supporting sqlite3/mysql5)

That said: the first code is somewhat older, but should still be fine if
you don't need weird newer sqlite3 C APIs. The second is my current
preferred API but it is driver-agnostic, not sqlite3-specific. The CPDO C++
API is trivially simple to use, though. Feel free to contact me off-list
with questions.

Happy Hacking!

-- 
- stephan beal
http://wanderinghorse.net/home/stephan/
http://gplus.to/sgbeal
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] SQLite and C++

2012-06-13 Thread Arbol One
Anyone knows where I can find some examples of how C++ interfaces with SQLite? 
I just need to see some code that is functional and not just some snips of how 
it maybe-should-possibly work.
 TIA
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQLite and C++ in Linux

2010-10-07 Thread Richard Hipp
On Thu, Oct 7, 2010 at 5:47 PM, Dan Sabin  wrote:

> Hi,
>
> I'm trying to embed SQLite into a Linux application. It's written in C++
> and I'm having trouble getting the code to compile with the SQLite .c and .h
> files included. I get some of the following errors:
>
> ./MyProject/Debug/../src/sqlite3.c:16556: undefined reference to
> `pthread_mutexattr_init'
> ./MyProjec/Debug/../src/sqlite3.c:16557: undefined reference to
> `pthread_mutexattr_settype'
> ./MyProjec/Debug/../src/sqlite3.c:16559: undefined reference to
> `pthread_mutexattr_destroy'
>

Please add  -lpthread to the end of the gcc command-line.


>
> I looked and the  file is being included. I just don't know how
> sqlite.c can't find the functions. If you have any knowledge of where i can
> find out how to solve my problem it'd be appreciated. I've searched
> everywhere and i can't find any answers.
>
> Thank You,
> Dan
>



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


Re: [sqlite] SQlite and C works with "like" but not with "="

2008-06-17 Thread Wilson, Ron P
Also, don't forget trailing white space, e.g. "Hexion " != "Hexion".

RW

Ron Wilson, S/W Systems Engineer III, Tyco Electronics, 434.455.6453

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Igor Tandetnik
Sent: Saturday, June 14, 2008 10:55 AM
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] SQlite and C works with "like" but not with "="

"Daniel White" <[EMAIL PROTECTED]>
wrote in message news:[EMAIL PROTECTED]
>> Which way is it stored in the database? Show the output of this
>> statement:
>>
>> SELECT SongTitle FROM songs WHERE SongTitle like 'hexion';
>
> There are 8 records of Hexion in the database, so after a printout
> to the console with a carriage return after each value, I basically
> get:
> Hexion
> Hexion
> Hexion
> Hexion
> Hexion
> Hexion
> Hexion
> Hexion

And you are saying the statement

SELECT SongTitle FROM songs WHERE SongTitle='Hexion';

doesn't return any rows? With all due respect, I find it difficult to 
believe. Would it be possible for you to email a copy of the database 
file to me at [EMAIL PROTECTED] ? Perhaps a stripped-down version, 
with just enough data to reproduce the problem.

Igor Tandetnik 



___
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 and C works with "like" but not with "="

2008-06-16 Thread Daniel White
Thanks again Dan and Igor. Since I don't need to write
to the database (only read from it atm), collate binary
will do nicely.

I'll keep an eye on those error messages in future!

Dan


On Sun, 15 Jun 2008 09:13:52 +0100, Dan <[EMAIL PROTECTED]> wrote:

> On Jun 15, 2008, at 8:55 AM, Daniel White wrote:
>
>> Cheers both of you, it seems this problem is indeed
>> linked with the "no such collation sequence: iunicode"
>> error as Dan mentioned.
>>
>> After some research, I found out that the root of
>> the problem is unsurmountable at present. I quote from:
>> http://www.mediamonkey.com/forum/viewtopic.php?p=84197
>>
>> "It's a real shame that simple queries like "select *
>>  from Songs where SongTitle = 'ABC'" aren't viable.
>> However, SQLite doesn't have good collation included,
>> there's absolutely no support for Unicode sorting or
>> case insensitive comparisons. We will try to do something
>> about it, but to be honest, I don't know if there's any
>> easy fix..."
>>
>> ...and...
>>
>> "IUNICODE is our collation that's there in order to
>> support Unicode sorting - which SQLite can't do internally."
>>
>> Oh well, there are one or two 'hacks' around it. The first is
>> to use COLLATE BINARY, or COLLATE NOCASE after the SQL query.
>> This appears okay on the surface, but probably ignores
>> unicode chars or something. It may also slow down the query (?)
>>
>> The other idea is to simply use "LIKE 'xyz'" instead of
>> "= 'xyz'". To my limited knowledge, apart from the case
>> sensivity of the latter, these don't differ in the outcome,
>> because there are no % signs around the former statement.
>> Although it would be nice, I'm not too bothered about case
>> sensitivity for my purposes.
>>
>> Which solution would you guys recommend?
>
> Just using 'COLLATE BINARY' is a good idea. There is a pretty
> good chance that memcmp() and whatever is being used for IUNICODE
> are the same for the '=' operator. If you don't have any non-ASCII
> characters in the song names, this will almost certainly work.
>
> Using COLLATE BINARY will prevent SQLite from using any index
> created on the song_title column (as the index will have been
> created using IUNICODE).
>
> Or you could copy all the data into a new table - one that uses
> only the default available collation sequences:
>
>CREATE TEMP TABLE my_songs AS SELECT * FROM songs;
>
> then query my_songs instead of songs. That wouldn't help you any
> more than using COLLATE binary explicitly in every query though.
>
> Or you could ask the vendor for the source code to the IUNICODE
> collation function.
>
> Using SQLite's ICU extension to try to create an equivalent collation
> sequence is also possible, but a bit dangerous. If the collation
> sequence you create turns out to be "mostly compatible" instead of
> "completely compatible", then you might wind up with segfaults or
> a corrupted database at some point in the future.
>
> Dan.
>
>
>
>
>> Cheers, Dan
>>
>>
>>
>>> And you are saying the statement
>>>
>>> SELECT SongTitle FROM songs WHERE SongTitle='Hexion';
>>>
>>> doesn't return any rows?
>>
>> Correct. It's weird I know. I also tried with different
>> names in different fields (Artist etc.), and I get the
>> same problem. "like" is okay, but = doesn't work.
>>
>> Here are the files again:
>> http://www.skytopia.com/stuff/MMdatabase.zip   (1.6 M)
>> http://www.skytopia.com/stuff/sqlite.cpp   (1k)
>>
>> Dan
>>
>>
>> On Sat, 14 Jun 2008 15:54:50 +0100, Igor Tandetnik
>> <[EMAIL PROTECTED]>
>> wrote:
>>
>>> "Daniel White" <[EMAIL PROTECTED]>
>>> wrote in message news:[EMAIL PROTECTED]
> Which way is it stored in the database? Show the output of this
> statement:
>
> SELECT SongTitle FROM songs WHERE SongTitle like 'hexion';

 There are 8 records of Hexion in the database, so after a printout
 to the console with a carriage return after each value, I basically
 get:
 Hexion
 Hexion
 Hexion
 Hexion
 Hexion
 Hexion
 Hexion
 Hexion
>>>
>>> And you are saying the statement
>>>
>>> SELECT SongTitle FROM songs WHERE SongTitle='Hexion';
>>>
>>> doesn't return any rows? With all due respect, I find it difficult to
>>> believe. Would it be possible for you to email a copy of the database
>>> file to me at [EMAIL PROTECTED] ? Perhaps a stripped-down version,
>>> with just enough data to reproduce the problem.
>>>
>>> Igor Tandetnik
>>>
>>>
>>>
>>> ___
>>> sqlite-users mailing list
>>> sqlite-users@sqlite.org
>>> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>>
>>
>>
>> --
>> www.skytopia.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



-- 
www.skytopi

Re: [sqlite] SQlite and C works with "like" but not with "="

2008-06-15 Thread Dan

On Jun 15, 2008, at 8:55 AM, Daniel White wrote:

> Cheers both of you, it seems this problem is indeed
> linked with the "no such collation sequence: iunicode"
> error as Dan mentioned.
>
> After some research, I found out that the root of
> the problem is unsurmountable at present. I quote from:
> http://www.mediamonkey.com/forum/viewtopic.php?p=84197
>
> "It's a real shame that simple queries like "select *
>  from Songs where SongTitle = 'ABC'" aren't viable.
> However, SQLite doesn't have good collation included,
> there's absolutely no support for Unicode sorting or
> case insensitive comparisons. We will try to do something
> about it, but to be honest, I don't know if there's any
> easy fix..."
>
> ...and...
>
> "IUNICODE is our collation that's there in order to
> support Unicode sorting - which SQLite can't do internally."
>
> Oh well, there are one or two 'hacks' around it. The first is
> to use COLLATE BINARY, or COLLATE NOCASE after the SQL query.
> This appears okay on the surface, but probably ignores
> unicode chars or something. It may also slow down the query (?)
>
> The other idea is to simply use "LIKE 'xyz'" instead of
> "= 'xyz'". To my limited knowledge, apart from the case
> sensivity of the latter, these don't differ in the outcome,
> because there are no % signs around the former statement.
> Although it would be nice, I'm not too bothered about case
> sensitivity for my purposes.
>
> Which solution would you guys recommend?

Just using 'COLLATE BINARY' is a good idea. There is a pretty
good chance that memcmp() and whatever is being used for IUNICODE
are the same for the '=' operator. If you don't have any non-ASCII
characters in the song names, this will almost certainly work.

Using COLLATE BINARY will prevent SQLite from using any index
created on the song_title column (as the index will have been
created using IUNICODE).

Or you could copy all the data into a new table - one that uses
only the default available collation sequences:

   CREATE TEMP TABLE my_songs AS SELECT * FROM songs;

then query my_songs instead of songs. That wouldn't help you any
more than using COLLATE binary explicitly in every query though.

Or you could ask the vendor for the source code to the IUNICODE
collation function.

Using SQLite's ICU extension to try to create an equivalent collation
sequence is also possible, but a bit dangerous. If the collation
sequence you create turns out to be "mostly compatible" instead of
"completely compatible", then you might wind up with segfaults or
a corrupted database at some point in the future.

Dan.




> Cheers, Dan
>
>
>
>> And you are saying the statement
>>
>> SELECT SongTitle FROM songs WHERE SongTitle='Hexion';
>>
>> doesn't return any rows?
>
> Correct. It's weird I know. I also tried with different
> names in different fields (Artist etc.), and I get the
> same problem. "like" is okay, but = doesn't work.
>
> Here are the files again:
> http://www.skytopia.com/stuff/MMdatabase.zip   (1.6 M)
> http://www.skytopia.com/stuff/sqlite.cpp   (1k)
>
> Dan
>
>
> On Sat, 14 Jun 2008 15:54:50 +0100, Igor Tandetnik  
> <[EMAIL PROTECTED]>
> wrote:
>
>> "Daniel White" <[EMAIL PROTECTED]>
>> wrote in message news:[EMAIL PROTECTED]
 Which way is it stored in the database? Show the output of this
 statement:

 SELECT SongTitle FROM songs WHERE SongTitle like 'hexion';
>>>
>>> There are 8 records of Hexion in the database, so after a printout
>>> to the console with a carriage return after each value, I basically
>>> get:
>>> Hexion
>>> Hexion
>>> Hexion
>>> Hexion
>>> Hexion
>>> Hexion
>>> Hexion
>>> Hexion
>>
>> And you are saying the statement
>>
>> SELECT SongTitle FROM songs WHERE SongTitle='Hexion';
>>
>> doesn't return any rows? With all due respect, I find it difficult to
>> believe. Would it be possible for you to email a copy of the database
>> file to me at [EMAIL PROTECTED] ? Perhaps a stripped-down version,
>> with just enough data to reproduce the problem.
>>
>> Igor Tandetnik
>>
>>
>>
>> ___
>> sqlite-users mailing list
>> sqlite-users@sqlite.org
>> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
>
>
> -- 
> www.skytopia.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] SQlite and C works with "like" but not with "="

2008-06-14 Thread Igor Tandetnik
"Daniel White" <[EMAIL PROTECTED]>
wrote in message news:[EMAIL PROTECTED]
> Oh well, there are one or two 'hacks' around it. The first is
> to use COLLATE BINARY, or COLLATE NOCASE after the SQL query.
> This appears okay on the surface, but probably ignores
> unicode chars or something. It may also slow down the query (?)
>
> The other idea is to simply use "LIKE 'xyz'" instead of
> "= 'xyz'".

LIKE is case-insesnsitive in the same way COLLATE NOCASE is - just 
considering A-Z equal to a-z. It doesn't support Unicode either.

In fact, there ain't no such thing as "Unicode collation". Collation 
depends on locale. E.g. A (capital letter A with diaresis) comes after A 
in German, but after Z in Swedish.

I believe SQLite can be built with ICU support 
(http://www.icu-project.org/), which introduces a number of 
Unicode-aware collations. I'm not familiar with the details though.

Igor Tandetnik 



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


Re: [sqlite] SQlite and C works with "like" but not with "="

2008-06-14 Thread Daniel White
Cheers both of you, it seems this problem is indeed
linked with the "no such collation sequence: iunicode"
error as Dan mentioned.

After some research, I found out that the root of
the problem is unsurmountable at present. I quote from:
http://www.mediamonkey.com/forum/viewtopic.php?p=84197

"It's a real shame that simple queries like "select *
 from Songs where SongTitle = 'ABC'" aren't viable.
However, SQLite doesn't have good collation included,
there's absolutely no support for Unicode sorting or
case insensitive comparisons. We will try to do something
about it, but to be honest, I don't know if there's any
easy fix..."

...and...

"IUNICODE is our collation that's there in order to
support Unicode sorting - which SQLite can't do internally."

Oh well, there are one or two 'hacks' around it. The first is
to use COLLATE BINARY, or COLLATE NOCASE after the SQL query.
This appears okay on the surface, but probably ignores
unicode chars or something. It may also slow down the query (?)

The other idea is to simply use "LIKE 'xyz'" instead of
"= 'xyz'". To my limited knowledge, apart from the case
sensivity of the latter, these don't differ in the outcome,
because there are no % signs around the former statement.
Although it would be nice, I'm not too bothered about case
sensitivity for my purposes.

Which solution would you guys recommend?

Cheers, Dan



> And you are saying the statement
>
> SELECT SongTitle FROM songs WHERE SongTitle='Hexion';
>
> doesn't return any rows?

Correct. It's weird I know. I also tried with different
names in different fields (Artist etc.), and I get the
same problem. "like" is okay, but = doesn't work.

Here are the files again:
http://www.skytopia.com/stuff/MMdatabase.zip   (1.6 M)
http://www.skytopia.com/stuff/sqlite.cpp   (1k)

Dan


On Sat, 14 Jun 2008 15:54:50 +0100, Igor Tandetnik <[EMAIL PROTECTED]>  
wrote:

> "Daniel White" <[EMAIL PROTECTED]>
> wrote in message news:[EMAIL PROTECTED]
>>> Which way is it stored in the database? Show the output of this
>>> statement:
>>>
>>> SELECT SongTitle FROM songs WHERE SongTitle like 'hexion';
>>
>> There are 8 records of Hexion in the database, so after a printout
>> to the console with a carriage return after each value, I basically
>> get:
>> Hexion
>> Hexion
>> Hexion
>> Hexion
>> Hexion
>> Hexion
>> Hexion
>> Hexion
>
> And you are saying the statement
>
> SELECT SongTitle FROM songs WHERE SongTitle='Hexion';
>
> doesn't return any rows? With all due respect, I find it difficult to
> believe. Would it be possible for you to email a copy of the database
> file to me at [EMAIL PROTECTED] ? Perhaps a stripped-down version,
> with just enough data to reproduce the problem.
>
> Igor Tandetnik
>
>
>
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users



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


Re: [sqlite] SQlite and C works with "like" but not with "="

2008-06-14 Thread Dan

On Jun 14, 2008, at 9:08 PM, Daniel White wrote:

> The course of action I thought you implied was to change
> it from "hexion" to "Hexion", and so I hoped that would
> return the results, but it still doesn't.
>
> "Still" meaning, just like the small 'h', 'H' doesn't
> work either.
>

The answer is in the error message. You're missing a collation
sequence.

Dan.

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


Re: [sqlite] SQlite and C works with "like" but not with "="

2008-06-14 Thread Igor Tandetnik
"Daniel White" <[EMAIL PROTECTED]>
wrote in message news:[EMAIL PROTECTED]
>> Which way is it stored in the database? Show the output of this
>> statement:
>>
>> SELECT SongTitle FROM songs WHERE SongTitle like 'hexion';
>
> There are 8 records of Hexion in the database, so after a printout
> to the console with a carriage return after each value, I basically
> get:
> Hexion
> Hexion
> Hexion
> Hexion
> Hexion
> Hexion
> Hexion
> Hexion

And you are saying the statement

SELECT SongTitle FROM songs WHERE SongTitle='Hexion';

doesn't return any rows? With all due respect, I find it difficult to 
believe. Would it be possible for you to email a copy of the database 
file to me at [EMAIL PROTECTED] ? Perhaps a stripped-down version, 
with just enough data to reproduce the problem.

Igor Tandetnik 



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


Re: [sqlite] SQlite and C works with "like" but not with "="

2008-06-14 Thread Daniel White
> Which way is it stored in the database? Show the output of this
> statement:
>
> SELECT SongTitle FROM songs WHERE SongTitle like 'hexion';

There are 8 records of Hexion in the database, so after a printout
to the console with a carriage return after each value, I basically get:
Hexion
Hexion
Hexion
Hexion
Hexion
Hexion
Hexion
Hexion

I'm probably missing really obvious, but I can't for the life
of me figure out what. There are no hidden spaces before or
after "Hexion" in the database, so = should work too.

Dan


On Sat, 14 Jun 2008 15:26:08 +0100, Igor Tandetnik <[EMAIL PROTECTED]>  
wrote:

> "Daniel White" <[EMAIL PROTECTED]>
> wrote in message news:[EMAIL PROTECTED]
>> The course of action I thought you implied was to change
>> it from "hexion" to "Hexion", and so I hoped that would
>> return the results, but it still doesn't.
>
> Which way is it stored in the database? Show the output of this
> statement:
>
> SELECT SongTitle FROM songs WHERE SongTitle like 'hexion';
>
>>> You get the number of columns with sqlite3_column_count. The only
>>> way to
>>> get the number of rows is to retrieve all of them (e.g. by calling
>>> sqlite3_step in a loop).
>>
>> Thanks. I'm guessing the inability to obtain the number of rows
>> is an SQL design compromise rather than a fault with sqlite or
>> SQL in general.
>
> I'm not sure I understand the question. But imagine you were
> implementing a relational DBMS. You need to execute a query
>
> select * from someTable where someCondition;
>
> How would you go about figuring the number of records in the resultset,
> short of looking at every record in someTable and evaluating
> someCondition for each? Because if you do look at every record, then
> calculating the count is no easier or faster than just running the query
> and counting the rows.
>
> Igor Tandetnik
>
>
>
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users



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


Re: [sqlite] SQlite and C works with "like" but not with "="

2008-06-14 Thread Igor Tandetnik
"Daniel White" <[EMAIL PROTECTED]>
wrote in message news:[EMAIL PROTECTED]
> The course of action I thought you implied was to change
> it from "hexion" to "Hexion", and so I hoped that would
> return the results, but it still doesn't.

Which way is it stored in the database? Show the output of this 
statement:

SELECT SongTitle FROM songs WHERE SongTitle like 'hexion';

>> You get the number of columns with sqlite3_column_count. The only
>> way to
>> get the number of rows is to retrieve all of them (e.g. by calling
>> sqlite3_step in a loop).
>
> Thanks. I'm guessing the inability to obtain the number of rows
> is an SQL design compromise rather than a fault with sqlite or
> SQL in general.

I'm not sure I understand the question. But imagine you were 
implementing a relational DBMS. You need to execute a query

select * from someTable where someCondition;

How would you go about figuring the number of records in the resultset, 
short of looking at every record in someTable and evaluating 
someCondition for each? Because if you do look at every record, then 
calculating the count is no easier or faster than just running the query 
and counting the rows.

Igor Tandetnik 



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


Re: [sqlite] SQlite and C works with "like" but not with "="

2008-06-14 Thread Daniel White
The course of action I thought you implied was to change
it from "hexion" to "Hexion", and so I hoped that would
return the results, but it still doesn't.

"Still" meaning, just like the small 'h', 'H' doesn't
work either.

Dan also mentioned the capital letter thing so it
was a reply to him as well.

> You get the number of columns with sqlite3_column_count. The only way to
> get the number of rows is to retrieve all of them (e.g. by calling
> sqlite3_step in a loop).

Thanks. I'm guessing the inability to obtain the number of rows
is an SQL design compromise rather than a fault with sqlite or
SQL in general.

Dan



On Sat, 14 Jun 2008 14:34:12 +0100, Igor Tandetnik <[EMAIL PROTECTED]>  
wrote:

> "Daniel White" <[EMAIL PROTECTED]>
> wrote in message news:[EMAIL PROTECTED]
>> Funny you should mention the capital at the start
>> to make "Hexion". I thought of that just after I
>> posted. But it doesn't solve the problem unfortunately.
>> Zero results are still returned.
>
> What do you mean, "still" returned? I stated a fact, but didn't suggest
> any action. What exactly did you do that you hoped would remedy the
> situation, but failed to?
>
>> Oh one other quick question: Any way to get the number
>> of rows/columns after preperation without using
>> ssomething like sqlite3_get_table?
>
> You get the number of columns with sqlite3_column_count. The only way to
> get the number of rows is to retrieve all of them (e.g. by calling
> sqlite3_step in a loop).
>
> Igor Tandetnik
>
>
>
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users



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


Re: [sqlite] SQlite and C works with "like" but not with "="

2008-06-14 Thread Igor Tandetnik
"Daniel White" <[EMAIL PROTECTED]>
wrote in message news:[EMAIL PROTECTED]
> Funny you should mention the capital at the start
> to make "Hexion". I thought of that just after I
> posted. But it doesn't solve the problem unfortunately.
> Zero results are still returned.

What do you mean, "still" returned? I stated a fact, but didn't suggest 
any action. What exactly did you do that you hoped would remedy the 
situation, but failed to?

> Oh one other quick question: Any way to get the number
> of rows/columns after preperation without using
> ssomething like sqlite3_get_table?

You get the number of columns with sqlite3_column_count. The only way to 
get the number of rows is to retrieve all of them (e.g. by calling 
sqlite3_step in a loop).

Igor Tandetnik



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


Re: [sqlite] SQlite and C works with "like" but not with "="

2008-06-14 Thread Daniel White
Thanks Dan and Igor for clarifying the 5th param.
I'm guessing it's safe to leave it at 0 if I
just use one SQL statement then.

Funny you should mention the capital at the start
to make "Hexion". I thought of that just after I
posted. But it doesn't solve the problem unfortunately.
Zero results are still returned.

Oh one other quick question: Any way to get the number
of rows/columns after preperation without using
ssomething like sqlite3_get_table?

Dan



On Sat, 14 Jun 2008 05:23:00 +0100, Dan <[EMAIL PROTECTED]> wrote:

> On Jun 14, 2008, at 10:39 AM, Daniel White wrote:
>
>> Hi guys,
>>
>> My first post to this list, and I'm new to SQL in general too.
>>
>> Just a couple of questions to start:
>>
>> ***1:
>> In the sqlite3_prepare_v2 function, can someone explain
>> to me the 5th parameter better than the site's help can?
>>
>> I quote:
>> /* OUT: Pointer to unused portion of zSql */
>>
>> I'm a bit perplexed. zSql is just the SQL query string.
>> There isn't an unused portion really, and even if there
>> was, I can't imagine how it could be of use. I just want
>> SQlite to process the string up to the NULL terminator.
>>
>> I tend to use 0. eg:
>> sqlite3_prepare_v2(database,sqlstring,-1,&ppStmt,0);
>>
>> It seems to 'work'. However, I'm still curious as to what
>> that 5th parameter really does, or why you really need it.
>
> For when you have a string containing more than one SQL statement.
> i.e.
>
>"INSERT INTO songs VALUES(...) ; INSERT INTO songs VALUES(...) ; ..."
>
> If this string is passed to sqlite3_prepare_v2, the unused portion
> begins right after the first semi-colon.
>
>> ***2:
>> When I use the SQL query string:
>> "SELECT * FROM songs WHERE SongTitle like 'hexion'"
>>
>
> The song title is actually 'Hexion'. By default LIKE is case-
> insensitive,
> = is not.
>
> Dan.
>
>
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users



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


Re: [sqlite] SQlite and C works with "like" but not with "="

2008-06-13 Thread Dan

On Jun 14, 2008, at 10:39 AM, Daniel White wrote:

> Hi guys,
>
> My first post to this list, and I'm new to SQL in general too.
>
> Just a couple of questions to start:
>
> ***1:
> In the sqlite3_prepare_v2 function, can someone explain
> to me the 5th parameter better than the site's help can?
>
> I quote:
> /* OUT: Pointer to unused portion of zSql */
>
> I'm a bit perplexed. zSql is just the SQL query string.
> There isn't an unused portion really, and even if there
> was, I can't imagine how it could be of use. I just want
> SQlite to process the string up to the NULL terminator.
>
> I tend to use 0. eg:
> sqlite3_prepare_v2(database,sqlstring,-1,&ppStmt,0);
>
> It seems to 'work'. However, I'm still curious as to what
> that 5th parameter really does, or why you really need it.

For when you have a string containing more than one SQL statement.
i.e.

   "INSERT INTO songs VALUES(...) ; INSERT INTO songs VALUES(...) ; ..."

If this string is passed to sqlite3_prepare_v2, the unused portion
begins right after the first semi-colon.

> ***2:
> When I use the SQL query string:
> "SELECT * FROM songs WHERE SongTitle like 'hexion'"
>

The song title is actually 'Hexion'. By default LIKE is case- 
insensitive,
= is not.

Dan.


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


Re: [sqlite] SQlite and C works with "like" but not with "="

2008-06-13 Thread Igor Tandetnik
"Daniel White" <[EMAIL PROTECTED]>
wrote in message news:[EMAIL PROTECTED]
> My first post to this list, and I'm new to SQL in general too.
>
> Just a couple of questions to start:
>
> ***1:
> In the sqlite3_prepare_v2 function, can someone explain
> to me the 5th parameter better than the site's help can?
>
> I quote:
> /* OUT: Pointer to unused portion of zSql */

You can pass a string containing several statements separated by 
semicolons. sqlite3_prepare[_v2] processes the first such statement, and 
returns a pointer to the remaining string. By calling the function 
repeatedly, you can process all statements in a string.

This is useful for command-line interface, where the user may type 
several statements on a single line.

> ***2:
> When I use the SQL query string:
> "SELECT * FROM songs WHERE SongTitle like 'hexion'"
>
> ...it works fine (some results turn up). However, if I use
> "=" instead of "like", the database returns zero entries,

By default, = is case-sensitive and LIKE is case-insensitive.

Igor Tandetnik 



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


[sqlite] SQlite and C works with "like" but not with "="

2008-06-13 Thread Daniel White
Hi guys,

My first post to this list, and I'm new to SQL in general too.

Just a couple of questions to start:

***1:
In the sqlite3_prepare_v2 function, can someone explain
to me the 5th parameter better than the site's help can?

I quote:
/* OUT: Pointer to unused portion of zSql */

I'm a bit perplexed. zSql is just the SQL query string.
There isn't an unused portion really, and even if there
was, I can't imagine how it could be of use. I just want
SQlite to process the string up to the NULL terminator.

I tend to use 0. eg:
sqlite3_prepare_v2(database,sqlstring,-1,&ppStmt,0);

It seems to 'work'. However, I'm still curious as to what
that 5th parameter really does, or why you really need it.


***2:
When I use the SQL query string:
"SELECT * FROM songs WHERE SongTitle like 'hexion'"

...it works fine (some results turn up). However, if I use
"=" instead of "like", the database returns zero entries,
despite the fact that "hexion" is definitely a SongTitle in that
database.

My (small and immediately compilable) code and database
are available here:
http://www.skytopia.com/stuff/MMdatabase.zip   (1.6 M)
http://www.skytopia.com/stuff/sqlite.cpp   (1k)

MMdatabase.zip is my MediaMonkey music database (best player
ever natch!).

Cheers, Dan
-- 
www.skytopia.com
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Sqlite and C

2004-10-29 Thread Florian Boor
Hi,

> Someone have a link about little software like an address book
> write in ansi C with sqlite?

look at http://gpe.handhelds.org most of the applications that need to
store data use sqlite. e.g. gpe-contacts and gpe-todo (The database
interface of it is in libtododb.)

Greetings

Florian

-- 
The dream of yesterday  Florian Boor
is the hope of todayTel: 0271-771091-14 
and the reality of tomorrow.Fax: 0271-771091-19 
[Robert Hutchings Goddard, 1904][EMAIL PROTECTED] 

6C 44 30 4C 43 20 6B 61  16 07 0F AA E6 97 70 A8




[sqlite] Sqlite and C

2004-10-29 Thread Max
Someone have a link about little software like an address book
write in ansi C with sqlite?
Thanks 1K

Ciao Max
--
Secondo alcuni autorevoli testi di tecnica Aeronautica,
il calabrone non puĆ² volare, a causa della forma e del
peso del proprio corpo in rapporto alla superficie alare. 
Ma il calabrone non lo sa e perciĆ² continua a volare.
   Igor Sikorsky