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



[sqlite] Single quotes are causing misery

2005-03-16 Thread Peter Jay Salzman
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

-- 
Save Star Trek Enterprise from extinction: http://www.saveenterprise.com

GPG Fingerprint: B9F1 6CF3 47C4 7CD8 D33E  70A9 A3B9 1945 67EA 951D


RE: Re[2]: [sqlite] [ANN] SQLite Analyzer 3

2005-03-16 Thread Guru Kathiresan


> On how many this feature seems to you important?

If you are competing against free products you need to distinguish your
product and it is natural for people to ask for stuff that is not available
in the free stuff. If you fail to distinguish then people would just stick
with the freebie.

-Guru Kathiresan



[sqlite] Should Unary + Cast to a Number?

2005-03-16 Thread David Wheeler
Hi All,
Given the below script (using DBD::SQLite 1.08, which uses SQLite 
3.1.3), the output is just:

  +0 Cast: 2005-03-22T00:00:00
I'm wondering, however, if unary + shouldn't also be able to cast an 
expression to a number...shouldn't it?

Thanks,
David
#!/usr/bin/perl -w
use strict;
use DBI;
use constant SQLITE_FILE => shift;
my $dbh = DBI->connect_cached(
'dbi:SQLite:dbname=' . SQLITE_FILE, '', '', {
RaiseError  => 1,
PrintError  => 0,
}
);
END {
$dbh->disconnect;
$dbh->rollback;
}
$dbh->begin_work;
$dbh->do("CREATE TABLE foo (a TEXT)");
$dbh->do("INSERT INTO foo VALUES('2005-03-22T00:00:00')");
my $sth = $dbh->prepare("SELECT * FROM foo WHERE (substr(a, 6, 2) = 
?)");
$sth->execute('03');
while (my $row = $sth->fetchrow_arrayref) {
print "No Cast: $row->[0]\n";
}

$sth = $dbh->prepare("SELECT * FROM foo WHERE (+substr(a, 6, 2) = ?)");
$sth->execute('03');
while (my $row = $sth->fetchrow_arrayref) {
print "Unary Cast: $row->[0]\n";
}
$sth = $dbh->prepare("SELECT * FROM foo WHERE (substr(a, 6, 2)+0 = ?)");
$sth->execute('03');
while (my $row = $sth->fetchrow_arrayref) {
print "+0 Cast: $row->[0]\n";
}


Re[2]: [sqlite] [ANN] SQLite Analyzer 3

2005-03-16 Thread Sergey Startsev
Hello,

Thursday, March 17, 2005, 7:48:09 AM, you wrote:

>>From  a quick look at sqlite analyzer, I would say the following :

CM> 2. it has better looks than sqlite3Explorer
In next SQLite Analyzer will have ER-model editor (such as ErWin,
PowerBuilder).

CM> 3. it cannot update tables using an editable grid approach
SQLite Analyzer can it. May be it is a bug. I check it.

CM> 4. it does not have a visual query builder
On how many this feature seems to you important?

CM> 5. I am not sure it has ADO import/export capabilities
Now SQLite Analyzer hasn't import/export capabilities.



-- 
Best regards

 Sergey Startsev
 SQLite Analyzer - GUI tool to manage SQLite databases.
 http://www.kraslabs.com/sqlite/



Re: [sqlite] python script example

2005-03-16 Thread cross wind
Thanks Gehard. Finally, I am seeing the pattern on how the scripts
ought to be run.

On Thu, 17 Mar 2005 01:59:28 +0100, Gerhard Haering <[EMAIL PROTECTED]> wrote:
> On Thu, Mar 17, 2005 at 06:52:03AM +0800, cross wind wrote:
> > On my other computer I tried installing
> > pysqlite-2.0.alpha2.win32-py2.3.exe and rerun my test script, it also
> > failed on the same error. However, when I changed the import line to:
> >
> > import pysqlite2.dbapi2 as sqlite
> >
> > The test script worked. However the following scripts in
> > \Python23\Lib\site-packages\pysqlite2\test failed to run:
> >
> > dbapi.py
> > types.py
> >
> > I have the ff result:
> >
> > M:/Python23/pythonw.exe -u
> > "M:/Python23/Lib/site-packages/pysqlite2/test/dbapi.py"
> > 'import site' failed; use -v for traceback
> > Traceback (most recent call last):
> >   File "M:/Python23/Lib/site-packages/pysqlite2/test/dbapi.py", line 25, in 
> > ?
> > import pysqlite2.dbapi2 as sqlite
> > ImportError: No module named pysqlite2.dbapi2
> >
> > Why oh why?
> 
> Not much time, my girlfriend is sending me to bed :-P
> 
> But try this instead:
> 
> C:\tmp>c:\Python23\python.exe
> Python 2.3.5 (#62, Feb  8 2005, 16:23:02) [MSC v.1200 32 bit (Intel)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
> >>> from pysqlite2 import test
> >>> test.test()
> ...
> --
> Ran 51 tests in 0.031s
> 
> -- Gerhard
> 
> 
>


Re: [sqlite] python script example

2005-03-16 Thread Gerhard Haering
On Thu, Mar 17, 2005 at 06:52:03AM +0800, cross wind wrote:
> On my other computer I tried installing
> pysqlite-2.0.alpha2.win32-py2.3.exe and rerun my test script, it also
> failed on the same error. However, when I changed the import line to:
> 
> import pysqlite2.dbapi2 as sqlite
> 
> The test script worked. However the following scripts in
> \Python23\Lib\site-packages\pysqlite2\test failed to run:
> 
> dbapi.py
> types.py
> 
> I have the ff result:
> 
> M:/Python23/pythonw.exe -u 
> "M:/Python23/Lib/site-packages/pysqlite2/test/dbapi.py"
> 'import site' failed; use -v for traceback
> Traceback (most recent call last):
>   File "M:/Python23/Lib/site-packages/pysqlite2/test/dbapi.py", line 25, in ?
> import pysqlite2.dbapi2 as sqlite
> ImportError: No module named pysqlite2.dbapi2
> 
> Why oh why?

Not much time, my girlfriend is sending me to bed :-P

But try this instead:

C:\tmp>c:\Python23\python.exe
Python 2.3.5 (#62, Feb  8 2005, 16:23:02) [MSC v.1200 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from pysqlite2 import test
>>> test.test()
...
--
Ran 51 tests in 0.031s

-- Gerhard


signature.asc
Description: Digital signature


RE: [sqlite] [ANN] SQLite Analyzer 3

2005-03-16 Thread Cariotoglou Mike
>From  a quick look at sqlite analyzer, I would say the following :

1. it is not free
2. it has better looks than sqlite3Explorer
3. it cannot update tables using an editable grid approach
4. it does not have a visual query builder
5. I am not sure it has ADO import/export capabilities 

-Original Message-
From: Eugene Wee [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, March 16, 2005 7:57 PM
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] [ANN] SQLite Analyzer 3

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



Re: [sqlite] database table is locked

2005-03-16 Thread Marcel Strittmatter
SQLITE_BUSY - another process has the whole database locked
SQLITE_LOCKED - one sqlite3_step() is trying to read (or write)
   the same table that another sqlite3_step() is
   writing (or reading) using the same DB handle.
It sounds as if Mr. Strittmatter is getting the second error.
The cause of SQLITE_LOCKED is usually because you failed to
sqlite3_finalize() the previous statement.
Yes. That's right. I found the missing sqlite3_finalize() command. But 
why did it work on Linux and failed on  Windows? Maybe because I work 
with nfs on Linux? Whatever... my problem is solved. Thanks for the 
help!

Marcel


Re: [sqlite] python script example

2005-03-16 Thread cross wind
On my other computer I tried installing
pysqlite-2.0.alpha2.win32-py2.3.exe and rerun my test script, it also
failed on the same error. However, when I changed the import line to:

import pysqlite2.dbapi2 as sqlite

The test script worked. However the following scripts in
\Python23\Lib\site-packages\pysqlite2\test failed to run:

dbapi.py
types.py

I have the ff result:

M:/Python23/pythonw.exe -u 
"M:/Python23/Lib/site-packages/pysqlite2/test/dbapi.py"
'import site' failed; use -v for traceback
Traceback (most recent call last):
  File "M:/Python23/Lib/site-packages/pysqlite2/test/dbapi.py", line 25, in ?
import pysqlite2.dbapi2 as sqlite
ImportError: No module named pysqlite2.dbapi2

Why oh why?


On Wed, 16 Mar 2005 22:46:38 +0800, Ng Pheng Siong <[EMAIL PROTECTED]> wrote:
> On Wed, Mar 16, 2005 at 06:45:23PM +0800, cross wind wrote:
> > AttributeError: 'module' object has no attribute 'connect'
> 
> Mine's installed from source.
> 
> $ python2.3
> Python 2.3.4 (#1, Sep 27 2004, 11:38:44)
> [GCC 2.95.4 20020320 [FreeBSD]] on freebsd4
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import sqlite
> >>> cx = sqlite.connect('/tmp/1.db')
> >>> cu = cx.cursor()
> >>> cu.execute('create table t1 (a,b,c)')
> >>> cu.execute('insert into t1 values (1,2,3)')
> >>> cx.commit()
> >>> cu.execute('select * from t1')
> >>> print cu.fetchall()
> [('1', '2', '3')]
> 
> > ### What seems to be wrong? I have installed:
> > ### pysqlite-1.1.6.win32-py2.3.exe
> 
> Packaging error?
> 
> --
> Ng Pheng Siong <[EMAIL PROTECTED]>
> 
> http://sandbox.rulemaker.net/ngps -+- M2Crypto, ZServerSSL for Zope, Blog
> http://www.sqlcrypt.com -+- Database Engine with Transparent AES Encryption
>


Re: [sqlite] database table is locked

2005-03-16 Thread D. Richard Hipp
On Wed, 2005-03-16 at 22:40 +0100, Jakub Adamek wrote:
> Also the error description "database TABLE is locked" is sometimes wrong 
> because it is the whole database which is locked. Perhaps another error 
> code/message should be created for "database is locked" (e.g. with open 
> cursors).
> 

There are two different errors:

SQLITE_BUSY - another process has the whole database locked
SQLITE_LOCKED - one sqlite3_step() is trying to read (or write)
   the same table that another sqlite3_step() is
   writing (or reading) using the same DB handle.

It sounds as if Mr. Strittmatter is getting the second error.
The cause of SQLITE_LOCKED is usually because you failed to
sqlite3_finalize() the previous statement.
-- 
D. Richard Hipp <[EMAIL PROTECTED]>



Re: [sqlite] database table is locked

2005-03-16 Thread Jakub Adamek
Hello,
I had a similar experience, but there was too much code to create a 
simple bug report. Surprisingly, the error disappeared if I first made a 
"SELECT FROM table" before the "INSERT INTO table" on the same table.
Also the error description "database TABLE is locked" is sometimes wrong 
because it is the whole database which is locked. Perhaps another error 
code/message should be created for "database is locked" (e.g. with open 
cursors).

Jakub
Marcel Strittmatter wrote:
Hi all
When I try to insert data into a table, sqlite3 responses with 
SQLITE_ERROR and the error message: "database table is locked". I 
searched already for unfinalized statements but couln't find any. The 
insert statement is not executed while a query is active...

The problem exists only on Windows (local storage), on Linux everything 
(except known nfs problems) works well (same code).

My question: Is there a "easy" way to test if a table is locked? Are 
there other possibilities to help debug such a problem (I already tried 
sqlit3_trace, but this doesn't help much because I don't see if a query 
is finalized or not).

Marcel


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


RE: [sqlite] Conversion mysql -> sqlite

2005-03-16 Thread Reid Thompson
Peter Jay Salzman wrote:
> Hi all,
> 
> I know very little about mysql and sqlite - I've only played
> around a little bit with databases, so I'm a newbie in this area.
> 
> There's a blogger called Wheatblog that I've been trying to
> convert from mysql to sqlite so I don't have to run a full
> RDMBS deamon on my underpowered machine for just a single
> blog program.
> 
> I think I've successfully replaced all the mysql calls with
> wrapper functions that use sqlite functions.  There's just a
> few bits left that are causing errors, and I'm having trouble fixing
> them. 
> 
> Here's the bit of mysql sql that creates the database used by
> Wheatblog.  It came in the Wheatblog zip file.  I'm surprised
> to see the accent grave (`):
> 
> 
>CREATE TABLE `wheatblog_categories` (
>  `id` int(11) NOT NULL auto_increment,
>  `category` varchar(30) NOT NULL default '',
>  PRIMARY KEY  (`id`)
>) TYPE=MyISAM;
> 
>CREATE TABLE `wheatblog_comments` (
>  `id` int(11) NOT NULL auto_increment,
>  `comment_author_name` varchar(100) NOT NULL default '',
>  `comment_author_email` varchar(100) NOT NULL default '',
>  `comment_author_url` varchar(100) NOT NULL default '',
>  `comment_body` mediumtext NOT NULL,
>  `post_id` int(11) NOT NULL default '0',
>  `comment_month` int(2) NOT NULL default '0',
>  `comment_date` int(2) NOT NULL default '0',
>  `comment_year` int(4) NOT NULL default '0',
>  PRIMARY KEY  (`id`)
>) TYPE=MyISAM;
> 
>CREATE TABLE `wheatblog_posts` (
>  `id` int(11) NOT NULL auto_increment,
>  `day` varchar(10) default '',
>  `month` int(2) NOT NULL default '0',
>  `date` int(2) NOT NULL default '0',
>  `year` int(4) NOT NULL default '0',
>  `category` int(1) NOT NULL default '1',
>  `showpref` tinyint(1) default '1',
>  `body` mediumtext NOT NULL,
>  `title` varchar(100) default '',
>  `number_of_comments` int(11) NOT NULL default '0',  PRIMARY
>KEY  (`id`) ) TYPE=MyISAM;
> 
>INSERT INTO `wheatblog_categories` (id, category)
>  values (null, 'unfiled');
> 
> 
> And here's how I've tried to implement it on sqlite using
> PHP.  Note that
> DB_query() is a wrapper for sqlite_query().  I've changed the
> "auto_increment" to "INTEGER PRIMARY KEY", as the FAQ said.
> I'm very new to SQL, but I guess "INTEGER PRIMARY KEY" and
> "NOT NULL" aren't separated by commas?
> 
> 
>function Create_Wheatblog_Database( $db )
>{
>   $cmd =
>   "CREATE TABLE 'wheatblog_categories' (
> 'id' INTEGER PRIMARY KEY NOT NULL,
> 'category' varchar(30) NOT NULL default '',
>   ) TYPE=MyISAM;";   <---
> 
>   echo "$cmd";
>   DB_query($cmd, $db);
> 
> 
>   $cmd =
>   "CREATE TABLE 'wheatblog_comments' (
> 'id' INTEGER PRIMARY KEY NOT NULL,
> 'comment_author_name' varchar(100) NOT NULL default '',
> 'comment_author_email' varchar(100) NOT NULL default '',
> 'comment_author_url' varchar(100) NOT NULL default '',
> 'comment_body' mediumtext NOT NULL,
> 'post_id' int(11) NOT NULL default '0',
> 'comment_month' int(2) NOT NULL default '0',
> 'comment_date' int(2) NOT NULL default '0',
> 'comment_year' int(4) NOT NULL default '0',   )
> TYPE=MyISAM;"; 
> 
>   DB_query($cmd, $db);
> 
> 
>   $cmd =
>   "CREATE TABLE 'wheatblog_posts' (
> 'id' INTEGER PRIMARY KEY NOT NULL,
> 'day' varchar(10) default '',
> 'month' int(2) NOT NULL default '0',
> 'date' int(2) NOT NULL default '0',
> 'year' int(4) NOT NULL default '0',
> 'category' int(1) NOT NULL default '1',
> 'showpref' tinyint(1) default '1',
> 'body' mediumtext NOT NULL,
> 'title' varchar(100) default '',
> 'number_of_comments' int(11) NOT NULL default '0',   )
> TYPE=MyISAM;"; 
> 
>   DB_query($cmd, $db);
> 
> 
>   $cmd =
>   "INSERT INTO 'wheatblog_categories' (id, category)
> values (null, 'unfiled');";
> 
>   DB_query($cmd, $db);
> 
>}
> 
> 
> It appears that the error is a "syntax error" near where my arrow
> (<--) is.  Can someone throw some charity my way?   Is there
> anything obviously
> wrong here?
> 
> Thanks,
> Pete

you might want to make changes along the lines of:

CREATE TABLE `wheatblog_categories` (
 `id` int(11) NOT NULL auto_increment,
 `category` varchar(30) NOT NULL default '',
 PRIMARY KEY  (`id`)
   )

to 

CREATE TABLE wheatblog_categories (
 id int(11) NOT NULL auto_increment,
 category varchar(30) NOT NULL default '',
 PRIMARY KEY  (id)
   )

reid


[sqlite] database table is locked

2005-03-16 Thread Marcel Strittmatter
Hi all
When I try to insert data into a table, sqlite3 responses with 
SQLITE_ERROR and the error message: "database table is locked". I 
searched already for unfinalized statements but couln't find any. The 
insert statement is not executed while a query is active...

The problem exists only on Windows (local storage), on Linux everything 
(except known nfs problems) works well (same code).

My question: Is there a "easy" way to test if a table is locked? Are 
there other possibilities to help debug such a problem (I already tried 
sqlit3_trace, but this doesn't help much because I don't see if a query 
is finalized or not).

Marcel


[sqlite] Where to put the files?

2005-03-16 Thread [EMAIL PROTECTED]
I understand that SQLite is good to learn something about sql.
I downloaded:
sqlite3-3.1.5.bin.gz ---> for SQLite 
tclsqlite-3.1.5.so.gz ---> for Tcl

Now, in order to try and build some simple web page containing tcl,
and see whether I can do some simple thing with it, where do I have to
put the files, on the server?
(My hosting 
[http://assistenza.aruba.it/kb/idx/0/142/article/Linguaggi_supportati_su_Hosting_Linux.html]
says that they have TCL without extra modules: I do not know the meaning of it.)
Of course I do not have root access to the server.
Thank you.
Luigi

P.S. Also, is there a place to find some easy examples...?


Re: [sqlite] Row count after prepare

2005-03-16 Thread Marcelo Zamateo
Leif:
There may be better solutions, but you don't need to scan the SQL, just  
put it as subquery:
sqlite3_printf "Select Count(*) from (%s)", pSQL
will do the work for you.
Remember what i said about Group by clauses.
Anyway i think a function like sqlite3_row_count(hStmt) would be fantastic.
Marcelo.





Re: [sqlite] mysql_insert_id() - how to do multiple inserts safely

2005-03-16 Thread Jay

In my code I do an insert into one table, get the row id of the
inserted record, then insert a related record in another table.

Do you need to surround your code with a "BEGIN IMMEDIATE" "COMMIT"
to ensure there are no other inserts into the first table between
the insert and get_inserted_rowid()? I did it that way thinking it's
a necessary precaution.


--- Clay Dowling <[EMAIL PROTECTED]> wrote:
> 
> Peter Jay Salzman said:
> > Do these two functions do the same thing?  Are there any surprises
> or
> > differences between the two?
> 
> They do close enough to the same thing that you don't need to worry
> about
> it.  SQLite ROWIDs can be recycled if you didn't define an
> autoincrement
> column and your table has deleted records.  It's generally not a
> problem
> if your app is good about maintaining referential integrity, but if
> you've
> been slack it can cause some interesting behavior.
> 
> Clay Dowling
> -- 
> Lazarus Notes from Lazarus Internet Development
> http://www.lazarusid.com/notes/
> Articles, Reviews and Commentary on web development
> 


-

"Lord Tarlington gazed upon the crazed Egyptian hieroglyphics on the walls of 
the ancient tomb of the petrified pharaoh, he vowed there would be no curse on 
him like on that other Lord, unless you count his marriage to Lady Tarlington 
who, when the lost treasure was found, will be dumped faster than that basket 
in the bulrushes."
  Melissa Rhodes
-

The Castles of Dereth Calendar: a tour of the art and architecture of Asheron's 
Call
http://www.lulu.com/content/77264



__ 
Do you Yahoo!? 
Take Yahoo! Mail with you! Get it on your mobile phone. 
http://mobile.yahoo.com/maildemo 


Re: [sqlite] Conversion mysql -> sqlite

2005-03-16 Thread Jeremy Hinegardner
On Tue, Mar 15, 2005 at 03:26:26PM -0500, Peter Jay Salzman wrote:
> Hi all,
> 
> I know very little about mysql and sqlite - I've only played around a little
> bit with databases, so I'm a newbie in this area.
> 
> There's a blogger called Wheatblog that I've been trying to convert from
> mysql to sqlite so I don't have to run a full RDMBS deamon on my
> underpowered machine for just a single blog program.

[snip]

There is a nice tool called SQLFairy[1] which can do sql translation
from one database's sql to another's.  I've used it many times for mysql
to sqlite sql conversion.  Right now it really only works with the
definition portion of the SQL (CREATE statements) and not with the data
manipulation statements.

enjoy,

-jeremy

[1] http://sqlfairy.sourceforge.net/

-- 

 Jeremy Hinegardner  [EMAIL PROTECTED] 



Re: [sqlite] Conversion mysql -> sqlite

2005-03-16 Thread Clay Dowling

Darren Duncan said:

> Having NOT NULL with a PRIMARY KEY is redundant, if not an outright
> error.  Defining something as a primary key is implicitly defining it
> to be both not null and distinct. -- Darren Duncan

You'll find NOT NULL and PRIMARY KEY to be perfectly compatible, at least
in SQLite and MySQL.  Many DB systems do allow NULLs in the primary key,
even if that's not strictly to the standard.  Heaven help the poor souls
who do put NULLs in the primary key, but some systems assume that you know
what you're doing.

Clay Dowling
-- 
Lazarus Notes from Lazarus Internet Development
http://www.lazarusid.com/notes/
Articles, Reviews and Commentary on web development


Re: [sqlite] mysql_insert_id()

2005-03-16 Thread Clay Dowling

Peter Jay Salzman said:
> Do these two functions do the same thing?  Are there any surprises or
> differences between the two?

They do close enough to the same thing that you don't need to worry about
it.  SQLite ROWIDs can be recycled if you didn't define an autoincrement
column and your table has deleted records.  It's generally not a problem
if your app is good about maintaining referential integrity, but if you've
been slack it can cause some interesting behavior.

Clay Dowling
-- 
Lazarus Notes from Lazarus Internet Development
http://www.lazarusid.com/notes/
Articles, Reviews and Commentary on web development


[sqlite] python script example

2005-03-16 Thread cross wind
### I have the following python test script:

import sqlite

cx = sqlite.connect('xyz.db')

cu = cx.cursor()
cu.execute('create table t1 (a,b,c)')
cu.execute('insert into t1 values (1,2,3)')
cx.commit()

cu.execute("select * from t1")
row = cu.fetchone()
print row

### When ran, I get the ff messages:

C:/PYTHON23/pythonw.exe -u  "Z:/devpy/test/sqlite.pyw"
Traceback (most recent call last):
  File "Z:/devpy/test/sqlite.pyw", line 1, in ?
import sqlite
  File "Z:\devpy\test\sqlite.pyw", line 3, in ?
cx = sqlite.connect('xyz.db')
AttributeError: 'module' object has no attribute 'connect'

### What seems to be wrong? I have installed:
### pysqlite-1.1.6.win32-py2.3.exe

### Thanks. This is my first attempt at python+sqlite.