Re: [Tutor] please help with sqlite replace function

2008-11-07 Thread Alan Gauld


"aivars" <[EMAIL PROTECTED]> wrote


Please try what sqlite3.version shows on your machine?


I also have ActiveState's python (mainly for its very good doc) and 
I get:

>>> import sqlite3
sqlite3.sqlite_version

'3.3.4'


Me too with Python 2.5.1 from Activestate.

Alan G 



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] please help with sqlite replace function

2008-11-07 Thread aivars
Hello, Denis,

Please try what sqlite3.version shows on your machine?

Thanks

aivars


2008/11/7 spir <[EMAIL PROTECTED]>:
> aivars a écrit :
>>
>> Thanks, John,
>> Yes it seems you are right. The ActiveState python version I have
>> installed have sqlite 2.3.2 only. I find it strange.
>
> I also have ActiveState's python (mainly for its very good doc) and I get:
 >>> import sqlite3
 sqlite3.sqlite_version
> '3.3.4'
>
> Denis
>
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] please help with sqlite replace function

2008-11-07 Thread Alan Gauld


"aivars" <[EMAIL PROTECTED]> wrote


Yes it seems you are right. The ActiveState python version I have
installed have sqlite 2.3.2 only. I find it strange.


Why? SQLite is a separate product. Python bundled the then
current version in its standard distribution, but time has moved on.
You have apparently installed a more recent version of SQLite.


I see that on a python website there is is a new version Python26


2.6 may or may not have the same version as you but regardless
you should be able to get the older version of Python to work
with the newer SQLite instal;l, provided the newer version has
a Python library available - which it usually has.


Mark Hammonds PythonWin to get other things for windows? Or maybe I
will reinstall ActiveState Python25 and install Python25 from the
official website


I don't thing the vanilla Python will make any difference. SQLite is
bundled with Python not with ActiveState.


Copying dll to c:\python25\DLLs directory did not help - it still
shows version sqlite version 2.3.2. which I also do not understand 
why


I think you might need to install more than the DLL. Check
the SQLite web site for a new Ptython interface and install
that version.

Alan G. 



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] please help with sqlite replace function

2008-11-06 Thread aivars
John, just to add to my previous post.

after copying sqlite3.dll (3.6.2) version into Python25\DLLs directory
and running

import sqlite3
dir(sqlite3)

>>> sqlite3.version
'2.3.2'

>>> sqlite3.version_info
(2, 3, 2)

>>> sqlite3.sqlite_version_info
(3, 6, 2)

>>> sqlite3.sqlite_version
'3.6.2'

and now my scrip happily runs with sqlite replace function.

I am just curious why there are so many different version properties
and why now they differ from sqlite3.version?
Of course it seems Python now is running sqlite version 3.6.2 since my
script accepts replace function

Thanks,
Aivars



2008/11/7 aivars <[EMAIL PROTECTED]>:
> Thanks, John,
> Yes it seems you are right. The ActiveState python version I have
> installed have sqlite 2.3.2 only. I find it strange.
> I see that on a python website there is is a new version Python26
> relesed. Should i go on and install Python26? I understand that I can
> install pure Python from python website and after that I can install
> Mark Hammonds PythonWin to get other things for windows? Or maybe I
> will reinstall ActiveState Python25 and install Python25 from the
> official website
>
> Copying dll to c:\python25\DLLs directory did not help - it still
> shows version sqlite version 2.3.2. which I also do not understand why
>
> Re user defined function - it is one of the ways to go probably
> quickest but I would like to have newer version of sqlite being
> already with python
>
> I am noob in Python still
>
> Thanks for your input
>
> Aivars
>
>
>
> 2008/11/6 John Fouhy <[EMAIL PROTECTED]>:
>> 2008/11/7 aivars <[EMAIL PROTECTED]>:
>>> I use python 2.5.2.2 (activestate), WinXP, sqlite version 3.6.2
>>
>> Hi Aivars,
>>
>> I believe python has its own built-in sqlite, rather than using the
>> version you installed independently.  So it is possible that the
>> python version of sqlite is older than 3.6.2 and does not yet have the
>> replace() function.
>>
>> (run 'import sqlite3' and then examine 'sqlite3.sqlite_version' to see
>> what version you are using)
>>
>> You could try replacing sqlite3.dll in your python25\dlls directory
>> with the DLL from your sqlite installation (make a backup first :-) ).
>>  Alternatively, you could define the replace() function in python and
>> then add it to your database: see
>> http://www.initd.org/pub/software/pysqlite/doc/usage-guide.html#creating-user-defined-functions
>> .
>>
>> HTH.
>>
>> --
>> John.
>>
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] please help with sqlite replace function

2008-11-06 Thread aivars
Thanks, John,
Yes it seems you are right. The ActiveState python version I have
installed have sqlite 2.3.2 only. I find it strange.
I see that on a python website there is is a new version Python26
relesed. Should i go on and install Python26? I understand that I can
install pure Python from python website and after that I can install
Mark Hammonds PythonWin to get other things for windows? Or maybe I
will reinstall ActiveState Python25 and install Python25 from the
official website

Copying dll to c:\python25\DLLs directory did not help - it still
shows version sqlite version 2.3.2. which I also do not understand why

Re user defined function - it is one of the ways to go probably
quickest but I would like to have newer version of sqlite being
already with python

I am noob in Python still

Thanks for your input

Aivars



2008/11/6 John Fouhy <[EMAIL PROTECTED]>:
> 2008/11/7 aivars <[EMAIL PROTECTED]>:
>> I use python 2.5.2.2 (activestate), WinXP, sqlite version 3.6.2
>
> Hi Aivars,
>
> I believe python has its own built-in sqlite, rather than using the
> version you installed independently.  So it is possible that the
> python version of sqlite is older than 3.6.2 and does not yet have the
> replace() function.
>
> (run 'import sqlite3' and then examine 'sqlite3.sqlite_version' to see
> what version you are using)
>
> You could try replacing sqlite3.dll in your python25\dlls directory
> with the DLL from your sqlite installation (make a backup first :-) ).
>  Alternatively, you could define the replace() function in python and
> then add it to your database: see
> http://www.initd.org/pub/software/pysqlite/doc/usage-guide.html#creating-user-defined-functions
> .
>
> HTH.
>
> --
> John.
>
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] please help with sqlite replace function

2008-11-06 Thread John Fouhy
2008/11/7 aivars <[EMAIL PROTECTED]>:
> I use python 2.5.2.2 (activestate), WinXP, sqlite version 3.6.2

Hi Aivars,

I believe python has its own built-in sqlite, rather than using the
version you installed independently.  So it is possible that the
python version of sqlite is older than 3.6.2 and does not yet have the
replace() function.

(run 'import sqlite3' and then examine 'sqlite3.sqlite_version' to see
what version you are using)

You could try replacing sqlite3.dll in your python25\dlls directory
with the DLL from your sqlite installation (make a backup first :-) ).
 Alternatively, you could define the replace() function in python and
then add it to your database: see
http://www.initd.org/pub/software/pysqlite/doc/usage-guide.html#creating-user-defined-functions
.

HTH.

-- 
John.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] please help with sqlite replace function

2008-11-06 Thread aivars
Hello,
I am stuck now.

I have a sqlite database with a table calendar (which is an auxilary
calendar table containing dates, years, months, days)
>From sqlite prompt I can run the following query without any problem:

SELECT  replace( datums,'-','' ) FROM calendar where Y='2008' and M='5'

It gives me back date strings in the format MMDD.

But when I run it from the python script it gives me the following error:

sqlite3.OperationalError: no such function: replace.

Script is simple as follows:

import sqlite3
spath=r'e:\pythonexamples\aivars2.db'
sql="SELECT  replace(datums,'-','') FROM Calendar where Y='2008' and M='5'"
cn=sqlite3.connect(spath)

for row in cn.execute(sql):
print row[0]

When I run the script without the replace function in select statement
it runs OK.


I use python 2.5.2.2 (activestate), WinXP, sqlite version 3.6.2

Thanks for any tip.
maybe I should ask this to sqlite mailing list?

Aivars
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor