Re: [sqlite] Building SQLite ... configure/make deprecated?

2009-05-04 Thread Eugene Wee
On Tue, May 5, 2009 at 3:59 AM, Rob Sciuk <r...@controlq.com> wrote:
> How does one actually obtain the "amalgamation", if not by using the
> configure/make scripts, complete with lemon and friends??

One way is by direct download of say,
sqlite-amalgamation-3.6.13.tar.gz, from
http://www.sqlite.org/download.html

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


Re: [sqlite] How do you guys use sqlite from C++?

2009-04-27 Thread Eugene Wee
Hi,

On Mon, Apr 27, 2009 at 8:06 PM, Vinnie <thev...@yahoo.com> wrote:
> Apparently I did come up with an original idea. Because none of the wrappers 
> from the archives are using variable argument lists. All these wrappers are 
> basically doing the same thing, a very thin layer on top of SQlite.
>
> My goal for a wrapper was to allow, using only a single function call, all of 
> the parameter binds and column values to get assigned. Having a separate 
> function call to retrieve each column or bind each parameter isn't much 
> better than straight SQLite (not that I'm complaining about SQLite, it 
> rocks!).
>
> Hasn't anyone else used variable argument lists for binding parameters and 
> what not?

The thing is, variable argument lists are not terribly popular in
"modern" C++. The trend is more for function call chaining. I have
seen at least one wrapper besides one that I have written that copies
the idea of overloaded shift operators for formatted input/output, but
applied to a database wrapper instead of the I/O stream library.
(Actually, considering that the prepared statement text is effectively
a format string, it would be more like copying Boost.Format.)

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


Re: [sqlite] the speed of embedded database engines, sqlite3 vs berkeley db, I'm confused

2009-04-23 Thread Eugene Wee
Hi,

On Fri, Apr 24, 2009 at 11:35 AM, liubin liu <7101...@sina.com> wrote:
>
> our project is using sqlite3, but found that the speed is too slow.
> I just tested the BerkeleyDB, and found that the speed is very fast. But I
> knew the sqlite3 is fast enough. And so I'm confused.
> I may be using sqlite3 in wrong way?

Instead of using sqlite3_mprintf() and sqlite3_exec() for your insert
statements, try using prepared statements.

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


Re: [sqlite] insert into multiple table

2009-04-22 Thread Eugene Wee
Hi,

On Wed, Apr 22, 2009 at 3:53 PM, dipendra
<dipendrakumar.jais...@gmail.com> wrote:
> i want to insert data in multiple table where one table depened upon the
> other table
> something like that---
>
> 1-insert into phone table
> insert into phone(id,phone) values (auto incremented ,0);
>
> 2-take the phone id value in integer variable
> integer phoneid=value;
>
> 3-pass this value in to address table
> insert into address(phoneid)values(phoneid);

You are probably looking to use sqlite3_last_insert_rowid().

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


Re: [sqlite] How to secure standalone SQLite db (Ken)

2009-04-20 Thread Eugene Wee
On Tue, Apr 21, 2009 at 1:43 PM, Ravi Thapliyal
<thapliyal.r...@gmail.com> wrote:
> Thanks Ken for replying, but I will appreciate if you brief me the process
> of encryption.

Check out the SQLite Encryption Extension
http://www.hwaci.com/sw/sqlite/see.html

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


Re: [sqlite] rows limit

2009-04-19 Thread Eugene Wee
Hi,

On Sun, Apr 19, 2009 at 12:41 PM, Randomcoder <randomcod...@gmail.com> wrote:
> Is there a maximum rows limit imposed on tables in sqlite ?
> I could not find this information anywhere on www.sqlite.org so that's
> why I'm asking here.

Referring to "Limits In SQLite":
http://www.sqlite.org/limits.html
It looks like the limit is more on database page size and number of
pages in the database file.

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


Re: [sqlite] Heuristics of when to vacuum

2009-04-12 Thread Eugene Wee
Hi,

On Mon, Apr 13, 2009 at 12:40 AM, Tito Ciuro <tci...@mac.com> wrote:
> One question, when I run the command I see that the fragmentation in
> "All tables" is greater than "All tables and indices". How can that
> be? The sum of all tables and their indices doesn't add up (10.6% +
> 7.5% ≠ 9.6%):

From the given information:
All tables
Percentage of total database..  66.4%
Fragmentation.  10.6%

All indices
Percentage of total database..  33.6%
Fragmentation.   7.5%

Now,
0.664 * 10.6 + 0.336 * 7.5 = 9.5584

This rounds to 9.6, which corresponds to:
All tables and indices
Fragmentation.........   9.6%

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


Re: [sqlite] Adding data with periods

2008-12-15 Thread Eugene Wee
Additionally, double quotes do have a "special meaning" in that they are
used to delimit identifiers.

Regards,
Eugene

On Mon, Dec 15, 2008 at 3:15 PM, John Stanton  wrote:

> Single quotes are SQL, as chosen by he designers.  It is good practice
> to stick to the standard rather than rely on extensions which vary from
> implementatiopn tio implementation.
>
> Mohd Radzi Ibrahim wrote:
> > It seems to works either way.
> >
> > I'm just wondering is there any hidden reason that single quote is
> > preferred? Portability?
> > Or is double-qoute has some kind of special meaning that we should use it
> > for that special purpose?
> >
> >
> > -radzi-
>
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Listing top 10 companies through COUNT?

2008-11-23 Thread Eugene Wee
Oops, and as for top 10, a LIMIT 10 clause may suffice, e.g.,
SELECT code, COUNT(code) AS code_count FROM companies GROUP BY code ORDER BY
code_count DESC LIMIT 10;

However, if you wish to show the next 10, then the next 10, etc, then you
might consider the technique described in this wiki article, if it is
applicable:
http://www.sqlite.org/cvstrac/wiki?p=ScrollingCursor

Regards,
Eugene Wee

On Sun, Nov 23, 2008 at 4:16 PM, Gilles Ganault <[EMAIL PROTECTED]>wrote:
>
>> Hello
>>
>>I tried a few things, but I still can't find how to do this: The
>> Companies table contains one row for each company; each row has a Code
>> field that indicates the type of activity this company is into.
>>
>> I'd like to count how many companies belong to each activity, and
>> display the top ten.
>>
>> This only displays the last code + total number of rows in the table:
>> SELECT code,COUNT(code) FROM companies ORDER by COUNT(code) DESC;
>>
>> This shows the same output:
>> SELECT code,COUNT(code) FROM boites ORDER BY code DESC;
>>
>> Any idea how to do this?
>>
>> Thank you for any tip.
>>
>> ___
>> 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] Listing top 10 companies through COUNT?

2008-11-23 Thread Eugene Wee
Hi,

It sounds like you want a GROUP BY clause, e.g.,
SELECT code, COUNT(code) AS code_count FROM companies GROUP BY code ORDER BY
code_count DESC;

Regards,
Eugene Wee

On Sun, Nov 23, 2008 at 4:16 PM, Gilles Ganault <[EMAIL PROTECTED]>wrote:

> Hello
>
>I tried a few things, but I still can't find how to do this: The
> Companies table contains one row for each company; each row has a Code
> field that indicates the type of activity this company is into.
>
> I'd like to count how many companies belong to each activity, and
> display the top ten.
>
> This only displays the last code + total number of rows in the table:
> SELECT code,COUNT(code) FROM companies ORDER by COUNT(code) DESC;
>
> This shows the same output:
> SELECT code,COUNT(code) FROM boites ORDER BY code DESC;
>
> Any idea how to do this?
>
> Thank you for any tip.
>
> ___
> 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] Value of sqlite3_bind_text and return type of sqlite3_column_text

2008-11-12 Thread Eugene Wee
Hi everyone,

I have been puzzled for quite some time as to why, in the SQLite C API, 
sqlite3_bind_text() takes a const char* as its third argument but 
sqlite3_column_text() returns a const unsigned char* instead.

Should they not involve the same type since one is a string input 
function while the other is the corresponding string output function?

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


Re: [sqlite] Proposed removal of (mis-)feature

2008-08-08 Thread Eugene Wee
Hi,

palmer ristevski wrote:
> He is my vote.
> I like the fact that conventions #1 and #2 make things compatible with other 
> databases.
> Does #3, by chance, do the same with another database not mentioned
> (eg. Oracle).
>
> If it does not have any compatibility with any other database,
> ONLY then I say that one should drop #3 quoting convention.
>
> Palmer
>   
I believe that MySQL allows double quotes to be used as string 
delimiters by default, but then this would not be a compatibility break 
with MySQL since MySQL also supports the standard use of single quotes 
for this purpose by default, and does not have the same "identifier, 
else a string" behaviour anyway.

Oh, and +1 to removing #3, if it matters now after so many votes in that 
direction :)

Regards,
Eugene

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


Re: [sqlite] Equivalent of mysql_real_escape_string() ?

2008-05-23 Thread Eugene Wee
Hi all,

Scott Baker wrote:
> As mentioned above the BEST way to do it is with prepared statement
> and bound variables. If you have to use raw SQL then just use the
> PDO::quote method:
> 
> http://php.web-ster.com/manual/en/pdo.quote.php
> 
> $conn = new PDO('sqlite:/home/lynn/music.sql3'); $string = 'Nice'; 
> print "Quoted string: " . $conn->quote($string) . "\n";
> 
> I'm open to discussion about whether or not this is this is still 
> vulnerable to SQL injection.
> 

The article Jay Kreibich linked to demonstrates a bug in MySQL's C API
that was fixed, and I suppose the fix was automatically reflected back
in PHP's MySQL extension when it was updated. SQLite's C API has no such
escaping function, so it depends on what PHP's SQLite PDO driver does to
implement the quoting.

I certainly hope that it is not vulnerable to SQL injection: if it is,
how do we handle the fact that we cannot bind a list of values to a
single parameter, and thus have to manually build the SQL statement if
we want to use IN ('x', 'y', 'z', ...), where the length and content of
the list is determined by the user? At the moment I would simply apply
PDO::quote to x, y, z (and the rest) individually.

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


Re: [sqlite] development vs production

2008-05-10 Thread Eugene Wee
On Sat, 2008-05-10 at 10:11 -0700, Jim Dodgen wrote:
> SQLite is rock solid.
> 
> Also I don't think it wise to develop on a different DBMS that the one 
> you are going to use in production.

Perhaps Sebastian Stephenson was referring to the "stand-in for an
enterprise database during demos or testing" use on the "Appropriate
Uses For SQLite" page:
http://www.sqlite.org/whentouse.html

That said, the other uses listed seem to make it clear that SQLite is
indeed suitable for production use.

Regards,
Eugene Wee


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


Re: [sqlite] Where To Put SQLite3.exe or SQLite3.dll for Windows Version of PHP?

2008-04-16 Thread Eugene Wee
Hi,

If you want the command line program for working with SQLite 3
databases, then sqlite3.exe is what you are looking for. Placing it in
the system path will do if you want to use it from everywhere.

Regards,
Eugene Wee

On Wed, 2008-04-16 at 20:06 -0400, Robert L Cochran wrote:
> Where exactly do I install the sqlite3.exe (or should I use sqlite3.dll)
> file for Microsoft Windows such that the Windows version of PHP  5.x
> will find it and make use of it? Is it sufficient to create a C:\Program
> Files\SQLite3 folder and put the SQLite 3.5.8 module(s) there, then edit
> my path variable to point to it?
> 
> Thanks
> 
> Bob Cochran
> Greenbelt, Maryland, USA


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


Re: [sqlite] PHP 4 and SQLite3

2008-03-13 Thread Eugene Wee
Hi,

This may be something of a non-solution, but you should pressure your 
host to upgrade to PHP 5 and provide the PDO extension from which you 
can use SQLite 3.

Note that the PHP website (http://www.php.net/downloads.php) states:
"Support for PHP 4 has been discontinued since 2007-12-31. Please 
consider upgrading to PHP 5.2."

Regards,
Eugene Wee

[EMAIL PROTECTED] wrote:
> Hello
> I must use SQLite functions of PHP 4, but it seems that these functions 
> doesn't works with SQLite 3.
> 
> What can I do?
> 
> best regards
> 
> Giovanni Rossati
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Beginners bad luck

2008-03-09 Thread Eugene Wee
Hi,

It looks like the PDO extension was not installed/enabled. This is a 
little unusual since "PDO ships with PHP 5.1", according to the PHP Manual.

I suggest that you install and enable the PDO extension. Read:
http://www.php.net/manual/en/ref.pdo.php
http://www.php.net/manual/en/ref.pdo-sqlite.php

Regards,
Eugene Wee

Aharon (Rony) Shapira wrote:
> I tried using PDO as follows :
> // create a SQLite3 database file with PDO and return a database handle
> 
> try{
> 
> $dbHandle = new 
> PDO('sqlite:'.$_SERVER['DOCUMENT_ROOT'].'/../pdoTutorial.sqlite3');
> 
> }catch( PDOException $exception ){
> 
> die($exception->getMessage());
> 
> }
> 
> 
>  but got the following error message:
> 
> Fatal error: Class 'PDO' not found in /home/zbfckla/public_html/Ocx.php on 
> line 14
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Query to Find number of distinct records

2008-02-27 Thread Eugene Wee
Hi,

Bharath Booshan L wrote:
> Yeah!! I got it right this time.
> 
> Select count(*) from ( select DISTINCT Name from TableA);
> 
> 
> But what's not getting into my mind is the difference b/w the following two
> queries:
> 
> Select count( Name) from TableA  -- works fine
> 
> Select count(DISTINCT Name) from TableA -- doesn't work, Any reason?

The thing is, it should work.

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


Re: [sqlite] Query to Find number of distinct records

2008-02-26 Thread Eugene Wee
Hi,

What is the error?

It seems to me that both of these should work:
select count(DISTINCT Name) from TableA
select count(DISTINCT Name) as nameCount from TableA

Regards,
Eugene Wee


Bharath Booshan L wrote:
> Thanks for your quick response,
> 
>> select count(DISTINCT Name) nameCount from TableA
> 
> This is not working :(. I am getting the same error.
> 
> --
> Bharath
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] insert on windows server 2003 very slow

2008-02-26 Thread Eugene Wee
Hi Angela,

Did you wrap the inserts in a transaction?

Regards,
Eugene Wee

Angela Kramer wrote:
> Hi,
> 
> I've written a java programm which reads data from a file and inserts 
> them into a sqlite database. In order to speed up this process I use 
> PreparedStatement.
> 
> On a computer running Windows XP inserting one line into the database 
> takes about 16 milliseconds. On a machine with Windows Server 2003 
> inserting the same line takes 150 to 200 milliseconds.
> 
> Where might this big difference come from?
> 
> Thank you for your answers in advance!
> Best regards
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Creating database in RAM

2008-02-21 Thread Eugene Wee
Hi Kirrthana,

you can open an in-memory database by using ":memory:" as the filename. 
Read: http://www.sqlite.org/capi3ref.html#sqlite3_open

Regards,
Eugene Wee

Kirrthana.M wrote:
> Hi all,
> 
> I just want to know wheather it is possible to create Sqlite3 database in
> RAM,if it is possible how can i do it in my C-program.
> Thanks in Advance.
> 
> Regards,
> Kirrthana
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] deleting syntax w/ PHP's PDO

2008-02-16 Thread Eugene Wee
Hi Sam,

Although what you refer to applies more generally (e.g., the SQLite C 
API has support for it), in this case the best reference would be the 
PHP Manual's entry on the PDO extension:
http://www.php.net/manual/en/ref.pdo.php

In particular, read the section on "Prepared statements and stored 
procedures". For further reading:
http://www.php.net/manual/en/function.PDO-prepare.php
http://www.php.net/manual/en/function.PDOStatement-bindParam.php

Regards,
Eugene Wee

Sam Carleton wrote:
> This might be a really basic question and it might be PHP related, not
> SQLite, I am not sure...
> 
> I know that the traditional way to do a delete would be this:
> 
> DELETE FROM users WHERE ipaddress = '192.168.1.1'
> 
> But I have also seen syntax where the actual statement does NOT
> contain the '192.168.1.1' but rather a ? and then the value is set as
> a parameter on, in my case,  PDO object.  It is my understanding that
> using the ? is much more secure then the traditional way above.  Where
> might I go to learn more about the ? way of doing a delete?
> 
> Sam
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] EXISTS and NULLs

2008-01-02 Thread Eugene Wee

Hi,

MySQL 5.0.41 and Postgresql 8.2.5 work as you described in their 
treatment of NULL. There were some minor syntax tweaks for CREATE TABLE 
and the second SELECT EXISTS, but other than that it was true for the 
first SELECT EXISTS and false for the second SELECT EXISTS.


Regards,
Eugene Wee

[EMAIL PROTECTED] wrote:

The current behavior of SQLite is to not do anything special
with NULLs in an EXISTS operator.  For example:

   CREATE TABLE t1(x);
   INSERT INTO t1 VALUES(NULL);
   SELECT EXISTS(SELECT x FROM t1);

The final SELECT above returns 1 (true) because an entry exists
in t1, even though that entry is NULL.  This makes logical sense
because if you wanted to know if there were non-null entries
you would say:

   SELECT EXISTS(SELECT x FROM t1 WHERE x NOT NULL);

But I have long ago learned that NULL values in SQL rarely
make logical sense, so I figure I better check.

Can somebody please confirm that this is the correct behavior
and that EXISTS does not do any special treatment of NULL
values?  Can somebody tell me what MySQL, PostgreSQL, Oracle,
and Firebird do in this case?

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





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



Re: [sqlite] SQLITE3 Prepare / Step

2007-10-17 Thread Eugene Wee

Hi,

Uma Krishnan wrote:

In SQLite3 one uses prepare/step to execute query. The question that I have is, 
when your stepping yields no more rows, and one has to re-execute the query, 
does one have to call the prepare statement again. If that's the case, what's 
the advantage of pre-compiling. If not, how does Sqlite3 knows it has to 
reissue the query.


You would use sqlite3_reset() or its equivalent in your wrapper's API.

Regards,
Eugene Wee

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



Re: [sqlite] Towards SQLite version 3.5.0

2007-08-28 Thread Eugene Wee
Would this be a good time to replace the older sqlite3_prepare() and 
sqlite3_prepare16() interfaces with what is currently the newer 
sqlite3_prepare_v2() and sqlite3_prepare16_v2() interfaces respectively? 
Admittedly they are definitely not among the "less frequently used 
interfaces", but such an incompatible change to existing interfaces 
would be best done in such a version number jump if it is ever intended.


Regards,
Eugene Wee

[EMAIL PROTECTED] wrote:

The transition from 3.4.2 to 3.5.0 will perhaps be the
largest single change to SQLite since 2.8->3.0.  There 
will not be that many visible changes, but a lot is 
changing behind the scenes.  Some less frequently used

interfaces will be changing in slightly incompatible
ways.  Users who have build customized OS intereface layers
or backends for SQLite will find that they are going to
need to do some rework.

SQLite version 3.5.0 is not close to being ready yet.
But it is to the point where the source code will
compile and pass many tests.  And so I would like to
take this opportunity to encourage people in the 
community to download the CVS HEAD and give it

a whirl in their applications.  Please let me know
about any serious issues you run across.

I have *started* to prepare documentation describing
the changes in 3.5.0.  This is draft documentation.
But for those who are interested, please visit

   http://www.sqlite.org/34to35.html
   http://www.sqlite.org/capi350ref.html

In particular, if your application uses a customized
OS interface for SQLite, you should read the 34to35.html
document to see exactly what will be involved in porting
your application to run with version 3.5.0.

The SQLite code currently in CVS HEAD is not ready for
production use.  We know that.  We know what many of the
problems are and Dan and I are working long hours to fix
them.  It's the problems that we *do not* know about that
are scary.  So that is why I am inviting the larger
community to have an early look and perhaps bring our
attention to issues sooner rather than later.

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


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




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



Re: [sqlite] how to create C functions and refer to them in sql

2007-08-06 Thread Eugene Wee

You are probably looking for sqlite3_create_function:
http://www.sqlite.org/capi3ref.html#sqlite3_create_function

Regards,
Eugene Wee

Chase wrote:


i need a trigger to create and insert a new guid into a table, but 
apparently there is no built-in function for creating guids in sqlite.


i can create the guid in C using uuid_generate() and then uuid_unparse() 
to get it into a string format.


but how can i call that c code from a trigger?

my understanding was that sqlite allows for user functions written in C 
and used from within your sql code, but i forget where i saw that and 
i'm so far unable to find in the docs where it shows how this is done.


anyone done this before?

- chase


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



Re: [sqlite] a c++ newbie question

2007-08-06 Thread Eugene Wee
  How can I do the same with prepare statements ? 
  Is it possible for me to prepare 10,000 in a loop and then surround them with BEGIN TRANSACTCION AND END TRANSACTION ? 


Yes. As an added benefit the preparation would mean that the SQL 
statement does not have to be parsed on each iteration of the loop.


  Actually I would appreciate a little code sample, if possible . 


This is a C++ example that does not do any error checking:

// Assume db is the database handle and stmt is the statement handle.
sqlite3_exec(db, "BEGIN TRANSACTION;", 0, 0, 0);
sqlite3_prepare_v2(db, "INSERT INTO foo (bar) VALUES (:bar);", -1, 
, 0);

for (int i = 0; i < 1; ++i)
{
sqlite3_bind_int(stmt, 1, i); // Bind i to the first parameter.
sqlite3_step(stmt); // Execute the statement.
sqlite3_reset(stmt);
}
sqlite3_finalize(stmt);
sqlite3_exec(db, "COMMIT TRANSACTION;", 0, 0, 0);

Regards,
Eugene Wee

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



Re: [sqlite] a c++ newbie question

2007-08-06 Thread Eugene Wee

Hi Stev,

Why not just use prepared statements?

Regards,
Eugene Wee

Stephen Sutherland wrote:

Hi ;
   
  I am trying to treat a string before passing it through my SQL statement into the database.
   
  I know that a  single apostrophe will break the SQL statement.
  So I have to replace them all to double apostrophes. 
  Question #1: 
  What may I ask is the c or C++ code to accomplish that ? 
  Initially I was using this simple scheme. 
   
  string str2("stephen's test . Bob's test");
   
  if (  str2.find("'"!= string::npos)

{
 str2.replace(str2.find('"), 1, "''");
  } 
  I know this doens't test for multiple single apostrophes. 
   
  But are there any other characters that will break the SQL statement ? 
   
  Has anyone  created a nice algorithm?

I actually have a situation where the user creates an XML file and the contents 
of the XML file gets dumped in the database. So there is opportunity for a 
hacker to create an XML file which has some SQL statements in it like ' DELETE 
TABLE X ;
   
  So any thoughts or existing code would be great.
   
  Thanks 
   
  Stev 


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



Re: [sqlite] auto_increment and not null

2007-06-28 Thread Eugene Wee

Hi Bruno,

Why not declare repres_id as INTEGER PRIMARY KEY? You can refer to the 
documentation on CREATE TABLE:

http://www.sqlite.org/lang_createtable.html

Regards,
Eugene Wee

Bruno S. Oliveira wrote:

Hi all,

I'm having some trouble in inserting data into a table which its
primary key is set as auto_increment and not null.
The table was created as follows:

CREATE TABLE te_representation (repres_id  INTEGER  AUTO_INCREMENT
NOT NULL ,layer_id  INTEGER ,geom_type  INTEGER ,geom_table  TEXT
,description  TEXT ,lower_x  REAL ,lower_y  REAL ,upper_x  REAL
,upper_y  REAL ,res_x  REAL ,res_y  REAL , num_cols  INTEGER ,num_rows
INTEGER ,initial_time  TEXT ,final_time  TEXT , PRIMARY KEY
(repres_id) );
CREATE INDEX te_idx_representation ON te_representation(layer_id);

And I'm executing this query:

INSERT INTO te_representation (layer_id, geom_type, geom_table,
description,lower_x, lower_y, upper_x, upper_y, res_x, res_y,
num_cols, num_rows) VALUES( 1, 4, 'Points1', '',3.40e+37,
3.40e+37, -3.40e+37, -3.40e+37, 0.00e+00,
0.00e+00, 0, 0);

The sqlite3 complains for the repres_id may not be NULL. I know that
it will work if I remove the repres_id's not null constraint, but this
I wouldn't like to do.

Does the sqlite auto_increment work only with primary keys WITHOUT the
not null constraint? The same query on the same table worked on MySQL.

I would appreciate any idea to work through this.

Thanks in advance.

Best regards.

Bruno




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



Re: [sqlite] Script Language

2007-03-09 Thread Eugene Wee

Hi,

Well, another way to stand on the shoulders of giants is to use the work of 
those giants to build up your own.


Regards,
Eugene Wee

John Stanton wrote:
Both Knuth and Wirth use the approach of a language of their own design 
to teach algorithms (and more).  Cesar, like Newton, will see far by 
standing on the shoulders of giants.


Samuel R. Neff wrote:

The original post said the goal is to teach algorithms, not programming
language design.  So for teaching algorithms I'd have to agree that 
using a

custom language is not the best choice.  For teaching how to write a
programming language, then of course you want to learn how to create your
own.

My $0.02.

Sam

 
-Original Message-
From: John Stanton [mailto:[EMAIL PROTECTED] Sent: Friday, March 
09, 2007 12:13 PM

To: sqlite-users@sqlite.org
Subject: Re: [sqlite] Script Language

It is not reinventing the wheel to develop the knowledge and skill to 
design an effective language then to implement it effectively.  This 
is an admirable project which will leave its young developer "loaded 
for bear".


Stef Mientki wrote:



Cesar Rodas wrote:


I am planning to develop a interpreted language with LEMON && FLEX. 
The main

goal is to provide a easy way to script commons actions, and to teach
algorithm in my University (National University of Asuncion - 
Paraguay).


The language have syntax as PHP and Python


I wonder why you're not using one of these ?
Looks to me you're reinventing the wheel,
while with a lot less effort you could give a better wheel a nice color


;-)


cheers,
Stef



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



Re: [sqlite] How do you unsubscribe?

2006-06-01 Thread Eugene Wee

Hi Richard,

Send an email to [EMAIL PROTECTED]

Actually, I sent an email to:
[EMAIL PROTECTED]

Hopefully it has resulted in an unsubscribe confirmation message sent to you, 
and replying to that email should unsubscribe you from this list.


Regards,
Eugene Wee

Richard Battagline wrote:

How do you unsubscribe?


Re: [sqlite] unsuscribe

2006-05-31 Thread Eugene Wee
Taking a quick look at the page on the SQLite website that tells about the 
mailing list:

http://www.sqlite.org/support.html

It seems that nothing is said about how to unsubscribe. The 'List-Unsubscribe' 
mail header has the email address:

[EMAIL PROTECTED]

I think that that webpage should be updated to state that one should send an 
email to that email address in order to get unsubscribed.


Oh, and if one's email address is [EMAIL PROTECTED], according to one of the 
first few emails I received from the mail manager, another way to unsubscribe is 
to send an email to:

[EMAIL PROTECTED]

Regards,
Eugene Wee

John Newby wrote:

whats with all these unsubscribe messages, they're beginning to do my head
in now!!!

On 31/05/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]>
wrote:


unsuscribe





Re: [sqlite] Purging the mailing list roles. Was: Please Restore Your Account Access

2006-05-29 Thread Eugene Wee

Hi,

I think many of the 1217 active subscribers are people like me who tune in to 
the list but only contribute once in a blue moon.


I do not have any objection to a "send email to keep your subscription active" 
idea, but I have never seen that used in the other mailing lists that I 
subscribe to.


Regards,
Eugene Wee

[EMAIL PROTECTED] wrote:

"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
dilettantes remain rude.Where we can almost borrow money from our 
earring.Hugo, the friend of Hugo and earns frequent flier miles 
with power drill near.


In order to be able to send messages to this mailing list,
the spammer above had to subscribe.  To subscribe means that
he had to respond to an email that was sent to the subscription
address.  Since his email address does not exist, I'm wondering
how he managed to pull this off.  Any ideas?

I have unsubscribed every account from "paypal.com" and "ebay.com".
All such accounts were of the form "[EMAIL PROTECTED]" or
"[EMAIL PROTECTED]", etc.  There were 7 such accounts.

After purging the accounts above, we are still left with 1217
active subscribers.  This seems like a lot to me.  I'm wondering
if some fraction of these might be inactive accounts, or accounts
belonging to people who have spam filters turned on to delete
incoming email from sqlite.org.  Does anybody have any ideas on
how we might remove people from the mailing list that do not
actually read messages from the mailing list?  When email bounces,
the user is removed automatically.  But email addresses that silently
absorb messages and never deliver them to a real human can linger
on the mailing list indefinitely.  


I wonder if I need to implement some kind of mechanism that requires
you to either send a message to the mailing list or else renew your
subscription every 3 months.  Does anybody have any experience with
other mailing lists that require such measures?

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





Re: [sqlite] Some advanced questions

2006-05-04 Thread Eugene Wee

Hi 'Unit 5',


3) I would like to test the validity of sql statements
before executing them.  So I thought I could use "db
complete" command.  But now I am not sure what "db
complete" command does.  In my tests, it returns 0
(false) regardless of the sql statement.  In fact the
only times I have gotton true is if the statement is
empty.  The statements are (all are valid and return
data):
  % db complete "select 2 * 2 "
  % db complete "select a from tab1"
  % db complete "select a from tab1 where a < 10"
  % db complete "select a from tab1 where a < 10
order by a"


You could take a look at:
http://www.sqlite.org/tclsqlite.html#complete

Basically, it does not validate the syntax, only checks that the SQL statement 
is complete (i.e. has a terminating semi-colon).


Regards,
Eugene Wee


Re: [sqlite] access to SQLite with OO

2006-01-30 Thread Eugene Wee

Hi,

a look through openoffice howto docs reveals:
http://documentation.openoffice.org/HOW_TO/data_source/SQLite.pdf

Regards,
Eugene Wee

Jay Sprenkle wrote:

Yes, I saw a driver in the programmers documentation section

On 1/28/06, Tomàs Eroles i Forner <[EMAIL PROTECTED]> wrote:

Hello all!
Is it possible to access and work with SQLite databases with Open Office
Base?








Re: [sqlite] Lib and H files

2005-09-22 Thread Eugene Wee

Hi,

Well, as Dennis Cote pointed out, you can get sqlite3.h by downloading
sqlite-source-3_2_6.zip

Still, it looks like renaming sqlite.h.in to sqlite3.h in the complete source
tarball is okay, but you should edit 2 preprocessor directives manually:
#define SQLITE_VERSION "--VERS--"
to
#define SQLITE_VERSION "3.2.6"

and

#define SQLITE_VERSION_NUMBER --VERSION-NUMBER--
to
#define SQLITE_VERSION_NUMBER 3002006

Regards,
Eugene Wee

Bradley Small wrote:
Thanks for the answers. I will for now assume that I can just take SQLITE.H.IN and rename it to sqlite3.h since, I don't see a sqlite3.h to extract from the sources. I guess at some point it would be nice to have all the nice un*x flavored text and building tools to work with. 


Regards ... Bradley M. Small
Senior Developer
MCC (Mobile Computing Corporation)
434-977-2732 - Office 
434-295-7414 - Fax

[EMAIL PROTECTED]
http://www.mobilecom.com









Re: [sqlite] SQLITE Documentation

2005-09-18 Thread Eugene Wee

Hi,

I decided to try and get the documentation on my computer myself, so did a 'make
doc' after extracting sqlite-3.2.6.tar.gz

The result was the message:
make: Nothing to be done for `doc'.

The doc subdirectory doesnt have a makefile, and trying make doc in the src
subdirectory returns:
make: *** No rule to make target `doc'.  Stop.

How then should I obtain the documentation, aside from that provided online, and
by manually sifting through the source? I'm on MS Windows XP, using MinGW +
MSYS. make doc was run through MSYS.

Thanks,
Eugene Wee

[EMAIL PROTECTED] wrote:


Try 'make doc' :))

Fanda

--- Forwarded message ---
From: "Firman Wandayandi" <[EMAIL PROTECTED]>
To: sqlite-users@sqlite.org, [EMAIL PROTECTED]
Cc:
Subject: Re: [sqlite] SQLITE Documentation
Date: Mon, 12 Sep 2005 10:08:36 +0200

On 9/12/05, ShepherdHill DB Subscriptions
<[EMAIL PROTECTED]> wrote:


Hi,

Can anyone point me to how I can get the full download of the


SQLITE > documentation in html? I will like to compile and maintain
the CHM


version of the document so that users can reference the


documentation > offline.


Dunno, I never found it. Might be the SQLite official team have it.
Currently I downloaded by myself all documentation, faqs and syntax
pages from sqlite.org, then fix the links and now it available
online on my box.



Best regards.

Chris.










Re: [sqlite] weird problem with windows 2000 PLEASE HELP!!!

2005-09-17 Thread Eugene Wee

Hi Dan,

Perhaps it's just my  uneducated opinion but your explanation sounds 
bogus...  Why would the folks who wrote SQLITE show it off as being so 
fast if, under win 2000, it only added 200 records every 25 seconds
It doesnt take anywhere near that long when you wrap the inserts in a 
transaction, right?


> And, why does adding a begin: / end:commit: around the whole loop speed
> up the operations so drastically???
You need to read the wiki:
http://www.sqlite.org/cvstrac/wiki?p=PerformanceTuning

Eugene Wee



Re: [sqlite] Unlucky number for the ROUND function

2005-08-30 Thread Eugene Wee

Hi,

On Windows XP testing for SQLite 3.2.5:
:.0 when using the sqlite3 executable downloaded
9.9 when running a program linked to an SQlite3 static library compiled by the 
MinGW port of GCC 3.4.2


Eugene Wee

Edzard Pasma wrote:

I found a number where the ROUND () function goes wrong:

SQLite version 3.2.5
Enter ".help" for instructions
sqlite> select round (9.95, 1);
:.0 


Sorry, it must be that I have bad luck today

Edzard Pasma

_
Tired of spam and viruses? Get a VolcanoMail account with SpamShield Pro and 
Anti-Virus technology! http://www.volcanomail.com/







Re: [sqlite] Binding a column name?

2005-07-10 Thread Eugene Wee

Hi,

Why not construct the SQL statement dynamically in the C/C++ code? That way your 
statement(s) would have variable column names before compilation.


Eugene Wee

Brown, Dave wrote:

Actually I doubt it can - since without the column name it can't create the
prepared statement byte code, right?

-Dave 


-Original Message-
From: Brown, Dave [mailto:[EMAIL PROTECTED] 
Sent: Saturday, July 09, 2005 8:46 PM

To: sqlite-users@sqlite.org
Subject: [sqlite] Binding a column name?


Is it possible for a bind variable to be a column name? I'd like to make a
query which is:

select  from MyTable;

and I'd like the column_name to be a bind variable. This doesn't work using
the straight sqlite3_bind_text() call on the statement "select ? from
MyTable;", which treats the column name as text and not part of the compiled
statement.

-Dave







[sqlite] Question on sqlite3_transfer_bindings()

2005-06-19 Thread Eugene Wee

Hi,
This concerns SQLite3.2

I noticed that there's a function in the C API:
int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);

How does one use it?
A comment in vdbeapi.c notes that "If the two statements contain a different 
number of bindings, then an SQLITE_ERROR is returned."
Unfortunately, the implementation of the function is rather opaque to me at this 
point, so I really have no idea how to use it, and would like to find out.


Thanks,
Eugene Wee



Re: [sqlite] Problem with "installing"

2005-06-08 Thread Eugene Wee

Hi,

You probably neglected to link to the dll.
What compiler are you using? GCC (i.e. g++)?

Eugene Wee

[EMAIL PROTECTED] wrote:

Hello,
 
I'd like to use the SQLite Library now for the first time, for my programs

which should run under Linux and Windows.
 
But I've got problems with the lib (I'm not very familar with .dll files). I

downloaded the Precompared Binary for Windows. In my progam I included the
sqlite3.h and I copied the sqlite3.dll into my project directory. But when I
compile it, I got error message about unresolved links, e.g. sqlite3_open()
 
I'm working normally with lib files, which I include with #pragma

comment(lib, "file.lib"); into my C++ program.
 
Can anyone help me?


Thanks in advance :)






Re: [sqlite] client/server

2005-06-07 Thread Eugene Wee

Hi,

Martín Schamis wrote:

1 .- This means that I can´t use a php on the web and the users acceding
to that page can`t modify the base ?

Not at all (if I correctly understand what you're trying to say).
For example, there exists a SQLite extension in PHP (which comes bundled by 
default in PHP5, but currently does not support SQLite3).


From what I see, the point that the documentation is trying to make is that 
SQLite is not suitable when you're dealing with a congested network environment. 
If you dont expect (many) users to be writing to the same database file 
simultaneously, SQLite may still be a feasible option.


Eugene Wee



Re: [sqlite] Re: philosophy behind public domain?

2005-06-05 Thread Eugene Wee

Hi,

Stefan Finzel wrote:


As a german citizen I'll try you explain my understanding of my 
countries law. The basic concept should be similar within central Europe 
(Austria, France, Italy, Spain ... but not Great Britain) as most 
countries laws evolved from the Roman law .
hmm... but in the case of copyright, Germany is a signatory of the Berne 
convention (right?), and so shouldnt the basic aspects of copyright remain the same?


First one just handles the mental ownership of  a piece of work. This 
can not be  given to another party.  In many cases this is worth nothing 
as is just bundles your name with your work.
This does differ from copyright somewhat, but apparently it is also covered in 
the Berne convention.

http://encyclopedia.thefreedictionary.com/moral%20rights

Second one handles the commercial and economical aspects. Of cause this 
is something total different. If you get paid for your work,  you 
sometimes loose this rights  to your  customer or employer immediatly.
If you still have this rights by your own  you are able to  
give/license/sell them like  every material thing.

Would this not correspond to copyright?
The right to sell is (usually) covered by copyright.

As I unterstand  the american way the customer or employer get the 
unrestricted usage rights under almost all circumstances. Additionally 
the author seems to have no right to be mentioned at all.
I'm not from the U.S., so my understanding may be skewed, but it seems that it 
depends on the license and/or contract.


Do not worry in casse an author tells you he gives you the right to use, 
to decide how to use AND(!!!) the right to modify it.
The thing is, the right to use is covered by patent law (which doesnt yet and 
hopefully never applies to software in Europe, methinks), while the right to 
modify is covered by copyright law. Both are not moral rights, from what I see.


Once again note, in Germany the right to modify code does not include 
removing the authors name.

That's because the right of attribution is a moral right.

Now most germans seems to accept the common GPL and BSD like copyrights. 
But I have problems understanding  many  restrictions/variatons of 
proprietary copyrights and just do not accept and use them.
In cases german citizens accepted a foreign license model ot contribute 
software, it would be nearly impossible to involve a German court 
whether for license nor for warranty aspects.
Yeah, there was a discussion on the differences in law in some European 
countries and the U.S. and similiar systems at the Open Source Initiative 
license discuss mailing list, but I wasnt paying attention :|


Eugene Wee

Disclaimer: I am not a lawyer, this is not legal advice/opinion.



Re: [sqlite] Re: philosophy behind public domain?

2005-06-04 Thread Eugene Wee
Well, since D. Richard Hipp would be the copyright holder if SQLite was 
licensed, that would be up to him, but he hasnt replied to the update yet.


If the licensing policy changes, probably the MIT license or (new/revised) BSD 
license would be good choices, though it seems to me (as a non-lawyer) that 
Larry Rosen's AFL would provide better protection against patent problems - but 
then whether or not it really would affect GPLed code is debatable, and that's 
not fun if you're just interested in coding.


Eugene Wee

Darren Duncan wrote:
Considering everything brought forth here, can anyone think of a reason 
not to have SQLite officially released from now on under a permissive 
free software license like the modified BSD license or the very similar 
X11 license?  Aside from a bit of time to search-n-replace some text, 
what would we stand to lose from such an action? -- Darren Duncan








Re: [sqlite] Comiling static libraries on Win32

2005-03-27 Thread Eugene Wee
Hi,
Just a guess here, but wouldnt the idea then be to (manually) compile 
each source file, then link the object files with your own?

With MinGW/GCC I used dlltool to get obtain libsqlite3.a from 
sqlite3.dll and sqlite3.def, passing the -lsqlite3 parameter to GCC at 
link-time. The only file I actually used from the source was sqlite3.h
I have no idea how standard my method is, though.

Eugene Wee
Clay Dowling wrote:
I highly suspect that I'm being a dolt here, but I'm not seeing the 
obvious thing.  I downloaded the preprocessed Win32 source code in hopes 
of compiling a static library for a Win32 release of a project that I'm 
working on.  Unfortunately I couldn't find a makefile in the 
preprocessed .zip file.

What's necessary to compile a static library, assuming that I don't have 
the cygwin or msys packages installed that could (potentially) run the 
configure program.  I noticed that SQLiteExplorer has a static link 
rather than using the DLL.  Would anybody care to share their trick with 
this poor benighted soul?  I've got the 3.2.0 source.

Clay Dowling



[sqlite] Prepared Statement Interface

2005-03-26 Thread Eugene Wee
Hi,
Are there any tutorials available to explain SQLite3's prepared 
statement interface further? I adapted from:
http://www.linuxjournal.com/article/7803

As a test, I created a database containing a single table [children]. I 
filled it with the names of 3 girls and 2 boys, and then tried to write 
a program that selects the boys and girls separately and printed their 
names.
However, I have difficulty in binding text with sqlite3_bind_text()
It appears that sqlite3_step() returns SQLITE_DONE at once, so my loop 
to print the names never runs.

I use SQLite 3.2.0 on Windows XP.
My compiler is the MinGW port of GCC 3.4.2
I used dlltool to generate libsqlite3.a
The source file used is attached as main.cpp
The database name is hardcoded as "mytest.db"
The SQL script that creates a chilren table is attached as children.sql
Basically I do a command line jig with:
g++ -c main.cpp
g++ -o test.exe main.o -lsqlite3
test
Hope someone can point out my mistakes, and point me in the right direction.
Thanks,
Eugene Wee
#include 
#include 

using std::cout;
using std::cerr;
using std::endl;

int main() {
sqlite3* db;
if (sqlite3_open("mytest.db", ) == SQLITE_OK) {
sqlite3_stmt* stmt;
#define QUERY "SELECT name FROM children WHERE sex=:sex"
if (sqlite3_prepare(db, QUERY, sizeof(QUERY), , NULL) == 
SQLITE_OK) {
int index = sqlite3_bind_parameter_index(stmt, ":sex");
#define SEX "'M'"
sqlite3_bind_text(stmt, index, SEX, sizeof(SEX), 
SQLITE_TRANSIENT);
cout << "The boys are:\n";
while (sqlite3_step(stmt) == SQLITE_ROW) {
cout << "- " << sqlite3_column_text(stmt, 0) << 
"\n";
}
sqlite3_reset(stmt);
#undef SEX
#define SEX "'F'"
sqlite3_bind_text(stmt, index, SEX, sizeof(SEX), 
SQLITE_TRANSIENT);
cout << "The girls are:\n";
while (sqlite3_step(stmt) == SQLITE_ROW) {
cout << "- " << sqlite3_column_text(stmt, 0) << 
"\n";
}
} else {
cerr << sqlite3_errmsg(db) << endl;
}
sqlite3_finalize(stmt);
} else {
cerr << sqlite3_errmsg(db) << endl;
}
sqlite3_close(db);
return 0;
}
CREATE TABLE children(
name TEXT,
sex  TEXT
);
INSERT INTO children VALUES('Amanda', 'F');
INSERT INTO children VALUES('Charis', 'F');
INSERT INTO children VALUES('Desmond', 'M');
INSERT INTO children VALUES('Bernadette', 'F');
INSERT INTO children VALUES('Charles', 'M');


Re: [sqlite] Contrib uploads

2005-03-24 Thread Eugene Wee
Hi,
have you considered using UPX to reduce the executable filesize?
http://upx.sourceforge.net
Eugene Wee
Cariotoglou Mike wrote:
1.1 mb I used the [EMAIL PROTECTED] devExpress grid, which is great
functionality-wise but bloats the 
Exe. 


-Original Message-
From: D. Richard Hipp [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 24, 2005 11:44 PM
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] Contrib uploads

On Thu, 2005-03-24 at 11:24 +0200, Cariotoglou Mike wrote:
I tried to upload a new version of sqlite3Explorer, and I 
got back the
error:
"Too much POST data". 
How big of an upload are we talking about?
--
D. Richard Hipp <[EMAIL PROTECTED]>





Re: [sqlite] Single quotes are causing misery

2005-03-16 Thread Eugene Wee
Hi,
I think the reason is that sqlite_escape_string() doubles single quotes 
to escape them.
However, you have magic_quotes_gpc set to 1 in php.ini
As such, incoming variables are escaped using backslashes.

A solution is to use stripslashes() on the incoming variables if 
get_magic_quotes_gpc() returns 1, since you cant change magic_quotes_gpc 
at runtime.
Alternatively, you can alter php.ini, but that's usually not practical.

Eugene Wee
Peter Jay Salzman wrote:
I've nearly completed converting Wheatblog to sqlite.  It's been quite a
learning experience!  I've come across a problem I haven't been able to
figure out, though.
Whenever I made a blog post that had a forward quote character (') in either
the title or the body of the post, I'd get an error.
After a little Googling, I changed my query to:
  $query = "INSERT INTO $database_table
 (id, day, month, date, year, category, title, body, showpref)
 VALUES (null,
 '" . sqlite_escape_string($_POST['the_day'])  . "',
 '" . sqlite_escape_string($_POST['the_month']). "',
 '" . sqlite_escape_string($_POST['the_date']) . "',
 '" . sqlite_escape_string($_POST['the_year']) . "',
 '" . sqlite_escape_string($_POST['the_category']) . "',
 '" . sqlite_escape_string($_POST['the_title']). "',
 '" . sqlite_escape_string($_POST['the_body']) . "',
 '" . sqlite_escape_string($_POST['the_showpref']) . "')";
   
  DB_query($query, $db);

and the definition of DB_query is:
   function DB_query($cmd, $db)
   {
  $retval = sqlite_query($db, "$cmd")
 or die('Query Error: ' . sqlite_error_string(sqlite_last_error($db)));
  return $retval;
   }
This works in the sense that forward quotes no longer generate an error.
However, whenever I print out a blog post, the forward quotes are all
escaped.   So if I post:
   This contains a ' character.
The post, when printed looks like:
   This contains a \' character.
What's the proper way to ensure that ' characters are properly quoted but
don't show up in the output?
Thanks!
Pete



Re: [sqlite] [ANN] SQLite Analyzer 3

2005-03-16 Thread Eugene Wee
Hi people,
I'm relatively new to SQLite, and would like some comments as to the GUI 
tools listed in the wiki.
In particular, does anyone actually use SQLite Analyzer 3 around here?
If so, how does it compare to sqlite3Explorer?

For reference sqlite3Explorer is the one on sqlite.org/contrib, and
SQLite Analyzer at
http://www.kraslabs.com/sqlite_analyzer.html
Thanks,
Eugene Wee