Re: [sqlite] Is it possible to insert UTF-8 strings in SQLITE3.EXE?

2012-05-12 Thread Frank Chang

Richard Hipp, Simon Slavin, Luuk, and Keith Metcalf Thank you for your replies 
to our question. 
 
Here is another way I found out how insert UTF-8 strings in SQLITE3.EXE. 
 
F:\sqlite3_6_16>sqlite3.exe mdName.dat
SQLite version 3.6.16
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> INSERT INTO PREFIX SELECT CAST(x'52C3B373' AS TEXT),'M','Ros','10';
sqlite> .quit 
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] store db from sqlite to online mysql or online sqlite

2012-05-12 Thread rebornishard

i browse but didn't find it 
there is 5 apps running sqlite and they will export it intoonline 
mysql or online sqlite database 
search from doc but still didn't get anything 
thanks
-- 
View this message in context: 
http://old.nabble.com/store-db-from-sqlite-to-online-mysql-or-online-sqlite-tp33802975p33802975.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] don't understand what "query" returns...

2012-05-12 Thread David Bicking
I don't know python, but because you have count(*) and no group by, it 
will only return one row, with the total rows that matched your where 
clause. The Item1, Item2, Item3 are arbitrary values that were in the 
two rows of your data.


You can either remove the count(*) and get both rows, or as someone else 
said, add a group by and get a row for each distinct values of Items 1-3.


David

On 05/12/2012 05:24 AM, philherna wrote:

Hi,


I am using sqlite commands in my python script to output data from a sqlite
database. My problem is however a Sqlite coding one.

I can open, and select simple elements from the database easily but I have
trouble for one specific issue.
For example, to select the content of the rows Item1 , Item2 and Item3 for
which Item55 is equal to 888, I type:

query = "select Item1,Item2,Item3, count(*) from %s where Item55 in (%s)" %
(Database,888)
c.execute(query)
results = c.fetchone()

If I type in Python:
   

print results# I get a the unique object which satisfies Item55=888.
   

(0.2, 0.5, 0.9, 1)
in which the 3 first elements are the values for Item1 , Item2 and Item3,
and the last element tells me that I have done "oneobject matching the
query", i.e. the selected columns for which Item55=888.
However, i am not quite sure that I really well understand why I am returned
this last element...

And for instance,
   

print results[1] # gives
   

0.5 # as expected

Now, if I want to select to more objects contained in an array, I can do:
Array = [888,999]
query = "select Item1,Item2,Item3, count(*) from %s where Item55 in (%s)" %
(Database,Array)
c.execute(query)
results = c.fetchall()

The fetchall command is supposed to return all the rows, as far as I
understand Sqlite... My problem is that i don't understand the query results
in this case. Indeed,
   

print results # gives
   

(0.2, 0.5, 0.9, 2)
in which the last element tells me (again, as far as I understand ...) that
I have submitted "2 queries", i.e. selected rows for which Item55=888 and
999. I would have expected a result to be a matrix with 2 rows, not a 1D
array...
   

print results[1][0] # gives
   

IndexError: list index out of range


Does anyone has an idea of what I am doing wrong here?
Thanks in advance !
   


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


Re: [sqlite] don't understand what "query" returns...

2012-05-12 Thread John Gillespie
You need something like :

query = "select Item1,Item2,Item3, count(*) from %s where Item55 in (%s) *group
by Item1,Item2,Item3*"

JG

On 12 May 2012 10:24, philherna  wrote:

>
> Hi,
>
>
> I am using sqlite commands in my python script to output data from a sqlite
> database. My problem is however a Sqlite coding one.
>
> I can open, and select simple elements from the database easily but I have
> trouble for one specific issue.
> For example, to select the content of the rows Item1 , Item2 and Item3 for
> which Item55 is equal to 888, I type:
>
> query = "select Item1,Item2,Item3, count(*) from %s where Item55 in (%s)" %
> (Database,888)
> c.execute(query)
> results = c.fetchone()
>
> If I type in Python:
> >> print results# I get a the unique object which satisfies Item55=888.
> (0.2, 0.5, 0.9, 1)
> in which the 3 first elements are the values for Item1 , Item2 and Item3,
> and the last element tells me that I have done "oneobject matching the
> query", i.e. the selected columns for which Item55=888.
> However, i am not quite sure that I really well understand why I am
> returned
> this last element...
>
> And for instance,
> >> print results[1] # gives
> 0.5 # as expected
>
> Now, if I want to select to more objects contained in an array, I can do:
> Array = [888,999]
> query = "select Item1,Item2,Item3, count(*) from %s where Item55 in (%s)" %
> (Database,Array)
> c.execute(query)
> results = c.fetchall()
>
> The fetchall command is supposed to return all the rows, as far as I
> understand Sqlite... My problem is that i don't understand the query
> results
> in this case. Indeed,
> >> print results # gives
> (0.2, 0.5, 0.9, 2)
> in which the last element tells me (again, as far as I understand ...) that
> I have submitted "2 queries", i.e. selected rows for which Item55=888 and
> 999. I would have expected a result to be a matrix with 2 rows, not a 1D
> array...
> >> print results[1][0] # gives
> IndexError: list index out of range
>
>
> Does anyone has an idea of what I am doing wrong here?
> Thanks in advance !
> --
> View this message in context:
> http://old.nabble.com/don%27t-understand-what-%22query%22-returns...-tp33796190p33796190.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] don't understand what "query" returns...

2012-05-12 Thread philherna

Hi,


I am using sqlite commands in my python script to output data from a sqlite
database. My problem is however a Sqlite coding one.

I can open, and select simple elements from the database easily but I have
trouble for one specific issue.
For example, to select the content of the rows Item1 , Item2 and Item3 for
which Item55 is equal to 888, I type:

query = "select Item1,Item2,Item3, count(*) from %s where Item55 in (%s)" %
(Database,888)
c.execute(query)
results = c.fetchone()

If I type in Python:
>> print results# I get a the unique object which satisfies Item55=888.  
(0.2, 0.5, 0.9, 1)
in which the 3 first elements are the values for Item1 , Item2 and Item3,
and the last element tells me that I have done "oneobject matching the
query", i.e. the selected columns for which Item55=888.
However, i am not quite sure that I really well understand why I am returned
this last element...

And for instance,
>> print results[1] # gives
0.5 # as expected

Now, if I want to select to more objects contained in an array, I can do:
Array = [888,999]
query = "select Item1,Item2,Item3, count(*) from %s where Item55 in (%s)" %
(Database,Array)
c.execute(query)
results = c.fetchall() 

The fetchall command is supposed to return all the rows, as far as I
understand Sqlite... My problem is that i don't understand the query results
in this case. Indeed, 
>> print results # gives
(0.2, 0.5, 0.9, 2)
in which the last element tells me (again, as far as I understand ...) that
I have submitted "2 queries", i.e. selected rows for which Item55=888 and
999. I would have expected a result to be a matrix with 2 rows, not a 1D
array...
>> print results[1][0] # gives
IndexError: list index out of range


Does anyone has an idea of what I am doing wrong here?
Thanks in advance !
-- 
View this message in context: 
http://old.nabble.com/don%27t-understand-what-%22query%22-returns...-tp33796190p33796190.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