[sqlite] Problem with sqlite in mac

2009-01-08 Thread anees ahamed
Hi,
I have a problem using sqlite in mac. When I run my application(executable
jar) from Windows OS, it works perfectly.
But when I try to launch the application from Mac, I get the following error

apples-imac:CreateJar apple$ java -jar TreeTable.jar
Unable to load sqlite: java.lang.
UnsatisfiedLinkError: no sqlite_jni in java.library.path

I use the db sqlite.jar


I had the same error when I executed the application in Windows

E:\Personal\1>java -jar TreeTable.jar
Unable to load sqlite: java.lang.UnsatisfiedLinkError: no sqlite_jni in
java.library.path


But, when I used sqlite_jni.dll, it solved the problem.


Can you kindly help me by saying what need to be done, so that this error
does not come anymore in mac.

Any help in this regard will be well appreciated with points.

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


Re: [sqlite] Retrieving NANs

2009-01-08 Thread Gerry Snyder
Sander Jansen wrote:
> I need to store NaNs in my database and able to retrieve them as well.
>
> Since sqlite will give me back 0.0 when I call sqlite3_column_double
> and a result contains a NAN,
> I was wondering what the best way is to retrieve a NAN from the database.
>
> Here's what I currently do in peudo code:
>
> if (sqlite3_column_type(column)==SQLITE_FLOAT)
>value = sqlite3_column_double(column);
> else
>value = NAN;
>
> Now, the doc says that
>
> "The value returned by sqlite3_column_type() is only meaningful if no
> type conversions have occurred as described below."
>
> Am I correctly assuming the "no type conversions have occurred"  means
> "no type conversions on that (row,column) of the result set"? I mean
> next time I call sqlite3_column_type() on the same column but on the
> next row of the result set, it will still give the correct answer?
>
> Thanks,
>
> Sander
>   
That sounds correct, yes.

One suggestion--if the column will always have either a float or NAN, 
why not just not insert anything if you have NAN, and then test for NULL?

HTH,


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


Re: [sqlite] Finding similar strings

2009-01-08 Thread htizo



Michael Schlenker-4 wrote:
> 
> htizo schrieb:
>> G'day,
>> Using sqlitev2.8.17 in php5 is there a way to look up a table for similar
>> strings (case insensitive)?
>> i.e. If I have the string "BLADEcatcher"
>> I want to find "blade_catcher" or "bladecatcher1" or even "bladecatcha"
>> so say 60% - 70% of characters the same.
> 
> sqlite 2.8.17 is from the stoneage..., why not use something more recent?
> 
> There are various options here.
> Not sure what would work with 2.8.17 though...
> 
> - use fulltext search support fts3 and hope the tokenizer/stemmer does
>   something useful to your strings
> 
> - use the soundex() function to calculate soundex values for your stored
>   strings and try to match with the soundex value of your search string
> 
> - write your own similarity function and use it like soundex() or in a
>   having clause.
> 
> - explode your stored strings into bi- or trigrams of letters and match
>   those
> 
> Typical thing to look for is Levenshtein distance, which you might know
> from
> PHP http://de3.php.net/levenshtein,
> n-gram matching http://en.wikipedia.org/wiki/N-gram
> 
> I would guess that n-gram matching is your best bet...
> 
> Michael
> 
> -- 
> Michael Schlenker
> Software Engineer
> 
> CONTACT Software GmbH   Tel.:   +49 (421) 20153-80
> Wiener Straße 1-3   Fax:+49 (421) 20153-41
> 28359 Bremen
> http://www.contact.de/  E-Mail: m...@contact.de
> 
> Sitz der Gesellschaft: Bremen
> Geschäftsführer: Karl Heinz Zachries, Ralf Holtgrefe
> Eingetragen im Handelsregister des Amtsgerichts Bremen unter HRB 13215
> 


G'day Michael,
Thank you for your reply.
My kids tell me I'm from the stone age so 2.8 should suit me well :-)
Actually it's the version installed by Debian Stable. I'm just introducing
myself to sqlite but have already found 1 reason to upgrade, so it is on the
cards, but for other reasons not yet.

Full Text Search (FTS1-3) is now another reason if I can work out how to
compile it. Thank you for introducing me to FTS3, Soundex() and levenshtein.
I need to look at n-gram further. Now I have a short (or long) learning
journey that looks rather fascinating. I'll send you the bill for my
headache painkillers.

Your reply was just what I hoped for. Thank you very much.

warm regards,
build




-- 
View this message in context: 
http://www.nabble.com/Finding-similar-strings-tp21351608p21363934.html
Sent from the SQLite mailing list archive at Nabble.com.

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


Re: [sqlite] How to create a Datatable [first steps of newbie]

2009-01-08 Thread htizo


Alessio Forconi wrote:
> 
> Hello everyone,
> 
> I am making the first steps with the programming and I want to help
> create a DataTable from a database sqlite with C #.
> Can you give me an example of how do I create it without using a
> dataset?
> Thank you very much for your help.
> 

Just in case you are not aware of MS newsgroups
http://www.tech-archive.net/Archive/DotNet/microsoft.public.dotnet.languages.csharp/2004-10/
microsoft.public.dotnet.languages.csharp

-- 
View this message in context: 
http://www.nabble.com/How-to-create-a-Datatable--first-steps-of-newbie--tp21355219p21363197.html
Sent from the SQLite mailing list archive at Nabble.com.

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


[sqlite] Retrieving NANs

2009-01-08 Thread Sander Jansen
I need to store NaNs in my database and able to retrieve them as well.

Since sqlite will give me back 0.0 when I call sqlite3_column_double
and a result contains a NAN,
I was wondering what the best way is to retrieve a NAN from the database.

Here's what I currently do in peudo code:

if (sqlite3_column_type(column)==SQLITE_FLOAT)
   value = sqlite3_column_double(column);
else
   value = NAN;

Now, the doc says that

"The value returned by sqlite3_column_type() is only meaningful if no
type conversions have occurred as described below."

Am I correctly assuming the "no type conversions have occurred"  means
"no type conversions on that (row,column) of the result set"? I mean
next time I call sqlite3_column_type() on the same column but on the
next row of the result set, it will still give the correct answer?

Thanks,

Sander







-- 
"And any fool knows a dog needs a home
A shelter from pigs on the wing"
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: How to get the total row number of a table by Sqlite more efficient��Y

2009-01-08 Thread Igor Tandetnik
jesuscheung  wrote:
> if your table's primary key is auto incremented, try:
>
> select max(id) from table
>
> this will be faster than using count()

... but would give incorrect answer if records are ever deleted from the 
table.

Igor Tandetnik 



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


Re: [sqlite] Java Database Access Code Generator

2009-01-08 Thread Mark Fraser
Actually, Firestorm DAO pretty much does what I want.  The problem with 
that solution is that it would leave me with the dilemma of limiting 
myself to 20 tables or paying for a $1000 license.

I have sqlite-jdbc.  It works fine.  But using raw jdbc is pretty painful. 

I am surprised there are not more tools like this for java.  I know 
there are some good ones for .Net.


Thomas DILIGENT wrote:
> Hello,
>
> In one hand, object persistence framework provide solutions starting from a
> description of your DB - object mapping.
> Unfortunately, these solutions are not easy to deploy. Does not seem to fit
> your need.
>
> In the other hand, if you just want java database access, you can have a
> look at sqlitejdbc.
> Simple to use and fits jdbc standard. I successfully used it.
>
>   
>> -Original Message-
>> From: sqlite-users-boun...@sqlite.org 
>> [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Mark Fraser
>> Sent: Thursday, January 08, 2009 12:24 AM
>> To: sqlite-users@sqlite.org
>> Subject: [sqlite] Java Database Access Code Generator
>>
>> Hello,
>>
>> I am looking for suggestions on a simple tool to generate 
>> java db access code that works with SQLite.
>>
>> Ideally what I want is something that will take a database 
>> schema file with create table statements as input and will 
>> generate the java classes necessary to encapsulate basic 
>> operations on the database.
>>
>> Obviously I have done a lot of searching already but have not 
>> found anything current that has the simplicity and 
>> functionality I am hoping for.
>>
>> Has anyone here successfully used such a tool with java/SQLite?
>>
>> Thanks.
>>
>> ___
>> 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-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] update PHP

2009-01-08 Thread Kees Nuyt
On Thu, 8 Jan 2009 15:29:33 +0100, n...@nobswolf.info (Emil
Obermayr) wrote in General Discussion of SQLite Database
:

>Hello list,
>
>I run a Windows XP system and want to "fill" the sqlite-DB through a
>ODBC-connection with data from other databases and then use it on a
>independant server (lighttp on USB-stick).
>
>The sqlite-version I get as ODBC-driver works nicely.
>
>The sqlite-version I get included in PHP as well.
>
>But both say "this is not a database" when I try to use the file of the one
>with the other.
>
>I guess it is because PHP is shipped with sqlite-version 3.3.7.
>
>How do I update the PDO-driver of PHP?

You could consider using the php_pdo_sqlite_external.dll
driver, which is just a stub that can be combined with any
recent sqlite3.dll.

Note: With Apache, the easiest location for sqlite3.dll is
the .../apache/bin directory. php_pdo will find it there.
Perhaps the same goes for lighttpd.

Fragment from php.ini:

extension=php_pdo.dll
; php_pdo_sqlite.dll usually has an old 
; version of sqlite compiled in.
; disabled: extension=php_pdo_sqlite.dll
;
; php_pdo_sqlite_external.dll loads
; a genuine sqlite3.dll
extension=php_pdo_sqlite_external.dll


>Thanks for help
>
>nobs

Hope this helps.
-- 
  (  Kees Nuyt
  )
c[_]
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] How to get the total row number of a table by Sqlite more efficient?

2009-01-08 Thread jesuscheung

if your table's primary key is auto incremented, try:

select max(id) from table

this will be faster than using count()
-- 
View this message in context: 
http://www.nabble.com/How-to-get-the-total-row-number-of-a-table-by-Sqlite-more-efficient%EF%BC%9F-tp20061797p21359430.html
Sent from the SQLite mailing list archive at Nabble.com.

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


Re: [sqlite] insert or replace

2009-01-08 Thread Jay A. Kreibich
On Thu, Jan 08, 2009 at 06:30:38AM -0800, liron.levy10 scratched on the wall:
> 
> i am trying to use the "insert or replace" query command , and "insert" is
> the command who executed  always even though the query is alredy exist. and
> the right command to use is "replace" command
> someone know what is the problem?

  A conflict only occurs on columns marked UNIQUE.  So you must be
  inserting an explicit value into a UNIQUE column that already has
  that value.

  Also, REPLACE is not an UPDATE.  If an existing column is found that
  would have caused a UNIQUE constraint violation, it is DELETEed, and
  then the new row is then INSERTed.  REPLACE does not convert an INSERT
  into an UPDATE.

   -j

-- 
Jay A. Kreibich < J A Y  @  K R E I B I.C H >

"Our opponent is an alien starship packed with atomic bombs.  We have
 a protractor."   "I'll go home and see if I can scrounge up a ruler
 and a piece of string."  --from Anathem by Neal Stephenson
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Fwd: memory usage

2009-01-08 Thread ed
I haven't looked much at the source but will give it a shot.Thanks for the
reply.

On Wed, Jan 7, 2009 at 12:31 PM, Kees Nuyt  wrote:

> On Wed, 7 Jan 2009 10:25:12 -0800, ed 
> wrote in General Discussion of SQLite Database
> :
>
> >Hello, I did not receive a reply to my question.Does anyone have any
> >information on this?
>
> Apparently not.
> I am not much of a source hacker, but perhaps you are.
> You might be able to intercept allocation and free calls and
> keep tallies per active database handle. You would have to
> add a few entrypoints for this.
>
> In short:
> Setup a hash table with counters for current and maximum
> allocation, use db handle as a key in the hashtable.
>
> Add an entrypoint that registers which db handle will be
> used in the next sqlite3_* call. Call that entrypoint before
> every sqlite3_* call.
>
> Add code to the "allocate" entrypoint:
>increment the current and maximum memory
>counter for the currently active db handle.
>
> Add code to the "free" entrypoint:
>decrement the current memory counter
>for the currently active db handle
>
> Add an entrypoint to report the contents of the hashtable.
>
> >thanks,
> >ed
> >
> >-- Forwarded message --
> >From: ed 
> >Date: Tue, Dec 30, 2008 at 10:02 AM
> >Subject: memory usage
> >To: sqlite-users@sqlite.org
> >
> >
> >Hello,
> >My multi-threaded application has various sqlite db's open simultaneously,
> >in memory using the :memory: keyword, disk based db's and at times, tmpfs
> >(ram) db's. Is there a way to view each individual database's memory
> usage?
> >
> >I found the functions sqlite3_memory_used() and
> >sqlite3_status(SQLITE_STATUS_MEMORY_USED, ...) but these look like they
> >provide memory statistics for all of sqlite, not per database.
> >
> >thanks,
> >ed
>
> Hope this helps.
> --
>  (  Kees Nuyt
>  )
> c[_]
> ___
> 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] How to create a Datatable [first steps of newbie]

2009-01-08 Thread Roosevelt Anderson
If you trying to extract data from a sqlite database to a DataTable
here is how you do it using the .Net data provider:

   SQLiteConnection conn = new SQLiteConnection("Data
Source=database.db");
conn.Open();
SQLiteDataAdapter apt = new SQLiteDataAdapter("select * from tbl", 
conn);
DataTable dt = new DataTable();
apt.Fill(dt);
conn.Close();




On Thu, Jan 8, 2009 at 11:28 AM, Alessio Forconi  wrote:
> Hello everyone,
>
> I am making the first steps with the programming and I want to help
> create a DataTable from a database sqlite with C #.
>
> Can you give me an example of how do I create it without using a
> dataset?
>
> Thank you very much for your help.
> ___
> 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] How to create a Datatable [first steps of newbie]

2009-01-08 Thread Alessio Forconi
Hello everyone,

I am making the first steps with the programming and I want to help
create a DataTable from a database sqlite with C #.

Can you give me an example of how do I create it without using a
dataset?

Thank you very much for your help.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] insert or replace

2009-01-08 Thread S B
Do you have a primary key on the table you're running the insert or replace
statement on?  I'm assuming you meant the record already exists.

SB

On Thu, Jan 8, 2009 at 9:30 AM, liron.levy10  wrote:

>
> i am trying to use the "insert or replace" query command , and "insert" is
> the command who executed  always even though the query is alredy exist. and
> the right command to use is "replace" command
> someone know what is the problem?
> --
> View this message in context:
> http://www.nabble.com/insert-or-replace-tp21352845p21352845.html
> Sent from the SQLite mailing list archive at Nabble.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


[sqlite] insert or replace

2009-01-08 Thread liron.levy10

i am trying to use the "insert or replace" query command , and "insert" is
the command who executed  always even though the query is alredy exist. and
the right command to use is "replace" command
someone know what is the problem?
-- 
View this message in context: 
http://www.nabble.com/insert-or-replace-tp21352845p21352845.html
Sent from the SQLite mailing list archive at Nabble.com.

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


[sqlite] update PHP

2009-01-08 Thread Emil Obermayr
Hello list,

I run a Windows XP system and want to "fill" the sqlite-DB through a
ODBC-connection with data from other databases and then use it on a
independant server (lighttp on USB-stick).

The sqlite-version I get as ODBC-driver works nicely.

The sqlite-version I get included in PHP as well.

But both say "this is not a database" when I try to use the file of the one
with the other.

I guess it is because PHP is shipped with sqlite-version 3.3.7.

How do I update the PDO-driver of PHP?

Thanks for help

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


Re: [sqlite] Copy database from memory... [resolved]

2009-01-08 Thread Zbigniew Baniewski
Sorry for noise: the problem was in quite other place.
-- 
pozdrawiam / regards

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


[sqlite] Copy database from memory to disk - sometimes works, sometimes not

2009-01-08 Thread Zbigniew Baniewski
Reading the paper
http://www.tcl.tk/community/tcl2004/Papers/D.RichardHipp/drh.html
I'm trying to use the ability to work using "in-memory-database". But there
is a problem: sometimes the data doesn't get transferred from memory back
onto disk. The procedure, that I wrote, is fairly simple:

#v+
# ...dblock & dbcomm are both active...
dblock eval {SELECT name FROM sqlite_master WHERE type='table'} {
  dblock eval "DELETE FROM $name"
}
dblock close

dbcomm eval {ATTACH $fullPath2dbase AS app}
dbcomm eval {SELECT name FROM sqlite_master WHERE type='table'} {
  dbcomm eval "INSERT INTO app.$name SELECT * FROM $name"
}
dbcomm eval {DETACH app}
dbcomm close
#v-

The problem is, that the above _in most cases_ works, but _just sometimes_
it isn't working - and because of this it's difficult to trace. Any
ideas, what can be the reason?
-- 
pozdrawiam / regards

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


Re: [sqlite] Finding similar strings

2009-01-08 Thread Michael Schlenker
htizo schrieb:
> G'day,
> Using sqlitev2.8.17 in php5 is there a way to look up a table for similar
> strings (case insensitive)?
> i.e. If I have the string "BLADEcatcher"
> I want to find "blade_catcher" or "bladecatcher1" or even "bladecatcha"
> so say 60% - 70% of characters the same.

sqlite 2.8.17 is from the stoneage..., why not use something more recent?

There are various options here.
Not sure what would work with 2.8.17 though...

- use fulltext search support fts3 and hope the tokenizer/stemmer does
  something useful to your strings

- use the soundex() function to calculate soundex values for your stored
  strings and try to match with the soundex value of your search string

- write your own similarity function and use it like soundex() or in a
  having clause.

- explode your stored strings into bi- or trigrams of letters and match
  those

Typical thing to look for is Levenshtein distance, which you might know from
PHP http://de3.php.net/levenshtein,
n-gram matching http://en.wikipedia.org/wiki/N-gram

I would guess that n-gram matching is your best bet...

Michael

-- 
Michael Schlenker
Software Engineer

CONTACT Software GmbH   Tel.:   +49 (421) 20153-80
Wiener Straße 1-3   Fax:+49 (421) 20153-41
28359 Bremen
http://www.contact.de/  E-Mail: m...@contact.de

Sitz der Gesellschaft: Bremen
Geschäftsführer: Karl Heinz Zachries, Ralf Holtgrefe
Eingetragen im Handelsregister des Amtsgerichts Bremen unter HRB 13215
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Finding similar strings

2009-01-08 Thread htizo

G'day,
Using sqlitev2.8.17 in php5 is there a way to look up a table for similar
strings (case insensitive)?
i.e. If I have the string "BLADEcatcher"
I want to find "blade_catcher" or "bladecatcher1" or even "bladecatcha"
so say 60% - 70% of characters the same.
I hope I've explained that sufficiently (cringe)

Thanking you in anticipation,
build
-- 
View this message in context: 
http://www.nabble.com/Finding-similar-strings-tp21351608p21351608.html
Sent from the SQLite mailing list archive at Nabble.com.

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


Re: [sqlite] selecting the top 3 in a group

2009-01-08 Thread Robert Citek
Thanks, Igor.  That worked perfectly.  Time for me to read up on rowid
and the subtleties of subselects.

Regards,
- Robert

On Thu, Jan 8, 2009 at 6:48 AM, Igor Tandetnik  wrote:
> select div, team from teams t1 where rowid in
> (select rowid from teams t2 where t1.div = t2.div
>  order by wins desc limit 3);
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] week number

2009-01-08 Thread PooLpi
Thanks MikeW,

Is there a way to do strftime %W with another function.
It don't seems to be possible with datetime.

Thanks

PooLpi

2009/1/8 MikeW 

> PooLpi  writes:
>
> >
> > Hello,
> >
> > Happy new year 2009 to the list ;)
> >
> > I'm working on weeks with Perl (DateTime module) and  Sqlite.
> >
> ...snip...
> > The ISO (ISO8601) definition says that the first week containing a
> Thursday
> > is week #1.
> >
> > My dates in the database are in this format : -MM-DD
> >
> > Why Sqlite gives me this #52 week number at the end of 2008?
> >
> > Thanks in advance,
> >
> > PooLpi
> >
> I think you will find that strftime %W quoted in the SQLite docs
> (follow the link from http://www.sqlite.org/lang_datefunc.html)
> does not use the ISO definition of week number, but rather the
> more simplistic Unix one.
>
> Regards,
> MikeW
>
>
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>



-- 



'Ebry haffa hoe hab im tik a bush'. Jamaican proverb
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] selecting the top 3 in a group

2009-01-08 Thread Igor Tandetnik
"Robert Citek" 
wrote in message
news:4145b6790901072206u73b367f1g3d377bb6962de...@mail.gmail.com
> How can I construction a SQL query to pick the top three (3) items in
> a group?
>
> I have a list of sports teams which are grouped into divisions, say A,
> B, C, D, etc.  At the end of the season I would like to get a list of
> the top three teams (those with the most wins) in each division.  If I
> wanted the best team from each division, I could write this:
>
> select div, team, max(wins) from teams group by div ;

select div, team from teams t1 where rowid in
(select rowid from teams t2 where t1.div = t2.div
 order by wins desc limit 3);

Igor Tandetnik



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


Re: [sqlite] week number

2009-01-08 Thread MikeW
PooLpi  writes:

> 
> Hello,
> 
> Happy new year 2009 to the list ;)
> 
> I'm working on weeks with Perl (DateTime module) and  Sqlite.
> 
...snip...
> The ISO (ISO8601) definition says that the first week containing a Thursday
> is week #1.
> 
> My dates in the database are in this format : -MM-DD
> 
> Why Sqlite gives me this #52 week number at the end of 2008?
> 
> Thanks in advance,
> 
> PooLpi
> 
I think you will find that strftime %W quoted in the SQLite docs
(follow the link from http://www.sqlite.org/lang_datefunc.html)
does not use the ISO definition of week number, but rather the
more simplistic Unix one.

Regards,
MikeW


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


Re: [sqlite] selecting the top 3 in a group

2009-01-08 Thread Edzard Pasma
--- robert.ci...@gmail.com wrote:

> I am still curious to know if there is a purely SQL way to do the same.

This can be achieved using group_concat:

select div,
rtrim (substr (s, 1, 10)) nr1,
rtrim (substr (s, 1, 10)) nr2,
rtrim (substr (s, 1, 10)) nr3
from (
select div, group_concat (substr (team || '  ', 1, 10), '') AS s
from (
select div, team
from teams
order by div, wins+0 desc)
group by div);

Don't believe this is ANSI SQL though.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] week number

2009-01-08 Thread PooLpi
Hello,

Happy new year 2009 to the list ;)

I'm working on weeks with Perl (DateTime module) and  Sqlite.

With the end of 2008 and the beginning of 2009 :

In my database, if i select dates at the end of 2008, it gives me :
 week #51 => 22-28 dec
 week #52 => 29-31 dec 

at the beginning of 2009 :
 week #0 => 1-4   jan
 week #1 => 5-11 jan

With the Perl and the DateTime, when i iterate from the end of 2008 to the
beginning of 2009:
 week #52 22-28 dec
 week #1   29 dec - 4 jan
 week #2   5-11 jan
Here it' OK (at least for me ;)

The ISO (ISO8601) definition says that the first week containing a Thursday
is week #1.

My dates in the database are in this format : -MM-DD

Why Sqlite gives me this #52 week number at the end of 2008?


Thanks in advance,

PooLpi


-- 



'Ebry haffa hoe hab im tik a bush'. Jamaican proverb
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] 600ms for simple query: How to optimize it?

2009-01-08 Thread MikeW
Lukas Haase  writes:

> 
> Hello,
> 
> Can somebody tell me why this (simple) query take so much time? This 
> query does nothing more than querying a table and JOINing two other 
> tables together.
> 
... snip ...
> 
> Does anybody have an idea what's going wrong here? How can I speed up 
> this query?
> 
> Thank you very much in advance,
> Luke

Silly question I know - presume this time does not include the prepare
(which should be done in advance) ?

MikeW



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


Re: [sqlite] Java Database Access Code Generator

2009-01-08 Thread Thomas DILIGENT
Hello,

In one hand, object persistence framework provide solutions starting from a
description of your DB - object mapping.
Unfortunately, these solutions are not easy to deploy. Does not seem to fit
your need.

In the other hand, if you just want java database access, you can have a
look at sqlitejdbc.
Simple to use and fits jdbc standard. I successfully used it.

> -Original Message-
> From: sqlite-users-boun...@sqlite.org 
> [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Mark Fraser
> Sent: Thursday, January 08, 2009 12:24 AM
> To: sqlite-users@sqlite.org
> Subject: [sqlite] Java Database Access Code Generator
> 
> Hello,
> 
> I am looking for suggestions on a simple tool to generate 
> java db access code that works with SQLite.
> 
> Ideally what I want is something that will take a database 
> schema file with create table statements as input and will 
> generate the java classes necessary to encapsulate basic 
> operations on the database.
> 
> Obviously I have done a lot of searching already but have not 
> found anything current that has the simplicity and 
> functionality I am hoping for.
> 
> Has anyone here successfully used such a tool with java/SQLite?
> 
> Thanks.
> 
> ___
> 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