On Fri, May 14, 2010 at 11:38 AM, Fabio Spadaro <fabiolinos...@gmail.com> wrote: > Hi, > > 2010/5/14 P Kishor <punk.k...@gmail.com> > >> On Fri, May 14, 2010 at 10:11 AM, Fabio Spadaro <fabiolinos...@gmail.com> >> wrote: >> > Hi, >> > >> > 2010/5/14 P Kishor <punk.k...@gmail.com> >> > >> >> On Fri, May 14, 2010 at 9:49 AM, Fabio Spadaro <fabiolinos...@gmail.com >> > >> >> wrote: >> >> > hi, >> >> > >> >> > 2010/5/14 P Kishor <punk.k...@gmail.com> >> >> > >> >> >> On Fri, May 14, 2010 at 9:01 AM, Fabio Spadaro < >> fabiolinos...@gmail.com >> >> > >> >> >> wrote: >> >> >> > I need to identify data types extracted from a >> >> >> > join between multiple tables without using cross-checking >> table_info >> >> more >> >> >> > pragmatic. >> >> >> > >> >> >> >> >> >> Could you clarify what you really want to do? Your question is not >> >> >> clear at all, at least to me. What do you mean by "using >> >> >> cross-checking table_info more pragmatic"? More pragmatic than what? >> >> >> >> >> >> > Is there a faster way to do it? >> >> >> > >> >> >> >> >> >> Faster than what? >> >> >> >> >> >> If you want data_types, you can use SELECT Typeof(column_name) >> >> >> >> >> >> >> >> >> >> >> >> >> >> > >> >> > I use python sqlite embedded and in my application I have a panel >> where >> >> you >> >> > can >> >> > type a query and see the results in a panel's grid >> >> > Now suppose that I type a query like "select >> >> > a.field1, b.field2 from table1 a, table2 b " such data >> >> > will be displayed in grid but I need to know what types of data I >> >> obtained. >> >> > How do it? >> >> >> >> >> >> SELECT a.field1, Typeof(a.field1), b.field2, Typeof(b.field2) >> >> FROM table1 a, table2 b... >> >> >> >> >> >> > >> > >> > It does not work, It always return data type text. >> > >> >> That is because your table has probably defined those columns as TEXT. >> Consider the following -- >> >> sqlite> CREATE TABLE t (a TEXT, b INTEGER); >> sqlite> INSERT INTO t VALUES ('foo', 5); >> sqlite> SELECT a, Typeof(a), b, Typeof(b) FROM t; >> a Typeof(a) b Typeof(b) >> ---------- ---------- ---------- ---------- >> foo text 5 integer >> sqlite> >> >> >> >> >> >> >> > > No, i'm sure. Probably typeof in python's sqlite is not supported very mell > or there is other explanation. >
Typeof() is a sqlite3 function. Maybe the Python implementation is overriding it. But, given that you are getting back "text" and not an error, shows that you are using some Typeof() function. Using the example db that I showed above, and the following Perl script, I get the desired and expected output #!/usr/local/bin/perl use DBI qw(:sql_types); $dbh = DBI->connect("dbi:SQLite:dbname=/Users/punkish/Data/punkish/foo","",""); $sth = $dbh->prepare("SELECT a, Typeof(a), b, Typeof(b) FROM t"); $sth->execute; while (my @row = $sth->fetchrow_array) { print (join ", ", @row) . "\n"; } ######## prints... foo, text, 5, integer -- Puneet Kishor http://www.punkish.org Carbon Model http://carbonmodel.org Charter Member, Open Source Geospatial Foundation http://www.osgeo.org Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor Nelson Institute, UW-Madison http://www.nelson.wisc.edu ----------------------------------------------------------------------- Assertions are politics; backing up assertions with evidence is science ======================================================================= _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users