Re: [sqlite] SQLite Suitability for Shopping Cart

2009-09-24 Thread Dan Kennedy

On Sep 24, 2009, at 7:04 PM, CityDev wrote:

>
> Thanks for that Sebastian.
>
> It does however surprise me. I believe Access Jet handles simultaneous
> activities. Indeed I've got a feeling it does row-locking rather than
> page-locking. It's odd that SQLite has such a limitation. Anyway,  
> you've
> saved me a lot of heartache.

It changed from page to row locking in version 4.

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


Re: [sqlite] Sqlite testing

2009-09-24 Thread ydlu
I create the "Windows CE 6.0" OS image, so the Console command windows was
included. I try to build "SQLite3.exe" but failed! So how to test SQLite3 on
WIndows CE environment on every build?

Thanks

On Wed, Sep 23, 2009 at 8:03 AM, Shane Harrelson  wrote:

> On Wed, Sep 23, 2009 at 12:22 AM, Roger Binns 
> wrote:
> > -BEGIN PGP SIGNED MESSAGE-
> > Hash: SHA1
> >
> > ydlu wrote:
> >> I am Windows CE software developer, so I am really, really want to learn
> how
> >> you built and test "sqlite3.exe" in Windows CE platform. so I can run a
> >> console command line in Windows CE enivroment.
> >
> > http://www.sqlite.org/testing.html
> >
> > Most likely TH3 is used.
> >
> > Roger
>
>
> As Roger guessed, we do indeed use TH3
> (http://www.sqlite.org/th3.html).   Most Windows CE platforms don't
> include a "console", so the standard TCL based test fixture would be
> tricky to port (PocketConsole would be would a tool you could use, but
> it looks to be no longer available).  Additionally, providing access
> to the 500+ test files on the test device would be cumbersome, as well
> as having sufficient resources (memory, etc.) on the device to execute
> all the tests.
>
> HTH.
> -Shane
>  ___
> 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] SQLite JDBC - org.sqlite.NativeDB.step taking up too much time

2009-09-24 Thread George Bills
Hi everyone - this might be a general JDBC question rather than an 
SQLite specific question, but I'm not sure.

I've got an app that's writing to an SQLite database using the latest 
SQLite JDBC driver ("v056, based on SQLite 3.6.14.2") from 
http://www.zentus.com/sqlitejdbc/.

I've done some basic profiling using hprof, and initially things are 
fine. But then my tables get quite large (e.g. 26 million / 7 million / 
6 million rows), and after this point, I find that a huge amount of my 
apps time is being spent in "org.sqlite.NativeDB.step".

Does anyone know why this method might be so expensive? I probably need 
to dig deeper with my profiling and find out exactly which methods are 
calling the expensive "step"s, but I'm fairly new to working with JDBC 
and any hints or suggestions would be helpful.

During the applications run, I'll be running a certain amount of selects 
and inserts, but in all cases, I'll be selecting or inserting 1 row at a 
time, so I wouldn't expect that iterating over my ResultSet (I assume 
this is what org.sqlite.NativeDB.step is doing) would be very expensive.

The code that does the selection of a row, given an SQL string and an 
array of string parameters is like:

 selectStatement = databaseConnection.prepareStatement(SQL);
 setStatementParameters(selectStatement, parameters);
 resultSet = selectStatement.executeQuery();
 singleResult = parseResultForSingleElement(resultSet, 
columnName);

The code that does the insertion of a row, given an SQL string and an 
array of string parameters is like:

 insertStatement = databaseConnection.prepareStatement(SQL);
 setStatementParameters(insertStatement, parameters);
 insertStatement.executeUpdate();
 resultSet = insertStatement.getGeneratedKeys();
 autoincrementPK = parseResultForSingleElement(resultSet, null);

parseResultForSingleElement is like:

 if (numColumns == 1 && res.next()) {
 E val;
 if (columnName != null) {
 val = (E) res.getObject(columnName);
 } else {
 val = (E) res.getObject(1);
 }
 if (res.wasNull()) {
 ret = new SQLVal(ResultStatus.RESULT_WAS_NULL);
 } else {
 ret = new SQLVal(val);
 }
 }

Thanks for any help.
George.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Tedious CSV import question

2009-09-24 Thread P Kishor
On Thu, Sep 24, 2009 at 9:21 PM, C. Mundi  wrote:
> On Thu, Sep 24, 2009 at 7:16 PM,  wrote:
>
>> On Thu, 24 Sep 2009, Rich Shepard wrote:
>>
>> > On Thu, 24 Sep 2009, C. Mundi wrote:
>> >
>> >> I just bit the bullet and did it.  Python has an excellent csv module,
>> >> capable of handling just about any dialect you're likely to encounter.
>>  I
>> >> am so grateful I did not have to write a parser for CSV.  In just a few
>> >> lines I can read the csv right into sqlite.  If anyone wants the code I
>> >> will post it here if deemed appropriate.

and, since there is more than one way to do it, an alternative

http://search.cpan.org/~makamaka/Text-CSV-1.13/lib/Text/CSV.pm

>>
>> Please send me a copy.
>>
>> Chris
>>
>> 
>> Christopher F. Martin
>> School of Medicine
>> Center for Digestive Diseases & Nutrition
>> CB# 7555, 4104 Bioinformatics Bldg.
>> University of North Carolina at Chapel Hill
>> Chapel Hill, North Carolina 27599-7555
>> Phone: 919.966.9340       Fax: 919.966.7592
>> ~~~
>>
>>
>> ___
>> sqlite-users mailing list
>> sqlite-users@sqlite.org
>> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>>
>
>
> Here you go, Chris.  Please note the disclaimer, which is as serious if
> somewhat overwrought.  I cannot offer support for this script, but I suspect
> you'll have no problem grokking it and improvements are always appreciated.
> Good luck!
>
> Carlos
>
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
>



-- 
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


Re: [sqlite] Tedious CSV import question

2009-09-24 Thread Dan Bishop
C. Mundi wrote:
> Hi.  I have scanned the list archives and Googled.  I may have missed
> something, but what I found was not sufficiently general or robust for my
> needs.
>
> Happily, sqlite has a very nice .output mode for CSV.  It correctly
> double-quotes fields when they contain a space or a comma, and it correctly
> 'escapes' double-quote literals as "".  Great!  I need to go the other way.
>
> I don't see an inverse .import mode in sqlite to handle the completely
> general CSV syntax.  As anyone who has ever tried knows, parsing compliant
> CSV is a lot harder than writing compliant CSV.
>
> I'm hoping someone will (please) tell me I missed something in the sqlite
> docs.  Otherwise, I guess I'll be using python's csv module to turn my CSV
> file into SQL insert statements.  This is likely to be an infequent task,
> but it has to be done perfectly.  So if someone knows of a command-line tool
> to turn CSV into SQL inserts, I would appreciate that too.
Here's one I just wrote.

#!/usr/bin/env python

"""Utility to import CSV files into an SQLite database."""

from __future__ import division

import csv
import getopt
import os
import sqlite3
import sys

USAGE = 'USAGE: csv2sqlite [-o dbfile] csvfile...'
DEFAULT_OUTPUT_FILE = 'a.db'

_INTEGER_MAX = (1 << 63) - 1
_INTEGER_MIN = -_INTEGER_MAX - 1

def identify_type(value):
"""
Identify the SQLite type for a value.
"""
try:
int_value = int(value)
if int_value < _INTEGER_MIN or int_value > _INTEGER_MAX:
return 'REAL'
return 'INTEGER'
except ValueError:
try:
float(value)
return 'REAL'
except ValueError:
return 'TEXT'

def common_type(values):
"""
Return the common type for a list of values.
"""
types = set(identify_type(value) for value in values if value)
if len(types) == 1:
return types.pop()
elif types == set(['INTEGER', 'REAL']):
return 'NUMERIC'
else:
return 'TEXT'

def add_table_from_file(dbconn, filename):
"""
Read a CSV file and add it as a database table.

dbconn   -- open database connection
filename -- path to the CSV file
"""
table_name = os.path.splitext(os.path.basename(filename))[0]
data = list(csv.reader(open(filename)))
if not data:
return
headers = data.pop(0)
num_columns = len(headers)
# Replace all empty strings with NULL
data = [[value or None for value in row] for row in data]
# Ensure that all rows have the same number of columns
for row in data:
for dummy in xrange(num_columns - len(row)):
row.append(None)
# Determine the appropriate type for each column
column_info = [(column_name, common_type(row[col] for row in data))
   for (col, column_name) in enumerate(headers)]
# Build the SQL statements
sql_create_table = 'CREATE TABLE IF NOT EXISTS "%s" (%s)' % \
(table_name, ', '.join('%s %s' % column for column in column_info))
sql_insert = 'INSERT INTO "%s" VALUES (%s)' % \
(table_name, ', '.join(['?'] * num_columns))
# Build the database table
dbconn.execute(sql_create_table)
for row in data:
dbconn.execute(sql_insert, row)

def _main(argv=None):
"""
Executed when this module is run as a script.
"""
if argv is None:
argv = sys.argv
options, args = getopt.getopt(argv[1:], 'o:', ['help'])
options = dict(options)
if '--help' in options:
print USAGE
else:
dbconn = sqlite3.connect(options.get('-o', DEFAULT_OUTPUT_FILE))
for filename in args:
add_table_from_file(dbconn, filename)
dbconn.commit()
dbconn.close()

if __name__ == '__main__':
_main()

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


Re: [sqlite] Tedious CSV import question

2009-09-24 Thread C. Mundi
On Thu, Sep 24, 2009 at 7:16 PM,  wrote:

> On Thu, 24 Sep 2009, Rich Shepard wrote:
>
> > On Thu, 24 Sep 2009, C. Mundi wrote:
> >
> >> I just bit the bullet and did it.  Python has an excellent csv module,
> >> capable of handling just about any dialect you're likely to encounter.
>  I
> >> am so grateful I did not have to write a parser for CSV.  In just a few
> >> lines I can read the csv right into sqlite.  If anyone wants the code I
> >> will post it here if deemed appropriate.
>
> Please send me a copy.
>
> Chris
>
> 
> Christopher F. Martin
> School of Medicine
> Center for Digestive Diseases & Nutrition
> CB# 7555, 4104 Bioinformatics Bldg.
> University of North Carolina at Chapel Hill
> Chapel Hill, North Carolina 27599-7555
> Phone: 919.966.9340   Fax: 919.966.7592
> ~~~
>
>
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>


Here you go, Chris.  Please note the disclaimer, which is as serious if
somewhat overwrought.  I cannot offer support for this script, but I suspect
you'll have no problem grokking it and improvements are always appreciated.
Good luck!

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


Re: [sqlite] Tedious CSV import question

2009-09-24 Thread C. Mundi
On Thu, Sep 24, 2009 at 6:45 PM, Rich Shepard wrote:

> On Thu, 24 Sep 2009, C. Mundi wrote:
>
> > I just bit the bullet and did it.  Python has an excellent csv module,
> > capable of handling just about any dialect you're likely to encounter.  I
> > am so grateful I did not have to write a parser for CSV.  In just a few
> > lines I can read the csv right into sqlite.  If anyone wants the code I
> > will post it here if deemed appropriate.
>
> Carlos,
>
>   How about sending me a copy?
>
> Thanks,
>
> Rich
>
> --
> Richard B. Shepard, Ph.D.   |  IntegrityCredibility
> Applied Ecosystem Services, Inc.|Innovation
>  Voice: 503-667-4517  Fax:
> 503-667-8863
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>


Here you go, Rich.  Please note the disclaimer, which is as serious if
somewhat overwrought.  I cannot offer support for this script, but I suspect
you'll have no problem grokking it and improvements are always appreciated.
Good luck!

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


Re: [sqlite] Tedious CSV import question

2009-09-24 Thread cmartin
On Thu, 24 Sep 2009, Rich Shepard wrote:

> On Thu, 24 Sep 2009, C. Mundi wrote:
>
>> I just bit the bullet and did it.  Python has an excellent csv module,
>> capable of handling just about any dialect you're likely to encounter.  I
>> am so grateful I did not have to write a parser for CSV.  In just a few
>> lines I can read the csv right into sqlite.  If anyone wants the code I
>> will post it here if deemed appropriate.

Please send me a copy.

Chris


Christopher F. Martin
School of Medicine
Center for Digestive Diseases & Nutrition
CB# 7555, 4104 Bioinformatics Bldg.
University of North Carolina at Chapel Hill
Chapel Hill, North Carolina 27599-7555
Phone: 919.966.9340   Fax: 919.966.7592
~~~


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


Re: [sqlite] Tedious CSV import question

2009-09-24 Thread Rich Shepard
On Thu, 24 Sep 2009, C. Mundi wrote:

> I just bit the bullet and did it.  Python has an excellent csv module,
> capable of handling just about any dialect you're likely to encounter.  I
> am so grateful I did not have to write a parser for CSV.  In just a few
> lines I can read the csv right into sqlite.  If anyone wants the code I
> will post it here if deemed appropriate.

Carlos,

   How about sending me a copy?

Thanks,

Rich

-- 
Richard B. Shepard, Ph.D.   |  IntegrityCredibility
Applied Ecosystem Services, Inc.|Innovation
 Voice: 503-667-4517  Fax: 503-667-8863
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Tedious CSV import question

2009-09-24 Thread C. Mundi
On Thu, Sep 24, 2009 at 12:37 PM, C. Mundi  wrote:

>
> Hi.  I have scanned the list archives and Googled.  I may have missed
> something, but what I found was not sufficiently general or robust for my
> needs.
>
> Happily, sqlite has a very nice .output mode for CSV.  It correctly
> double-quotes fields when they contain a space or a comma, and it correctly
> 'escapes' double-quote literals as "".  Great!  I need to go the other way.
>
> I don't see an inverse .import mode in sqlite to handle the completely
> general CSV syntax.  As anyone who has ever tried knows, parsing compliant
> CSV is a lot harder than writing compliant CSV.
>
> I'm hoping someone will (please) tell me I missed something in the sqlite
> docs.  Otherwise, I guess I'll be using python's csv module to turn my CSV
> file into SQL insert statements.  This is likely to be an infequent task,
> but it has to be done perfectly.  So if someone knows of a command-line tool
> to turn CSV into SQL inserts, I would appreciate that too.
>
> Thanks,
> Carlos
>

Following up my own post:

I just bit the bullet and did it.  Python has an excellent csv module,
capable of handling just about any dialect you're likely to encounter.  I am
so grateful I did not have to write a parser for CSV.  In just a few lines I
can read the csv right into sqlite.  If anyone wants the code I will post it
here if deemed appropriate.

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


Re: [sqlite] Tedious CSV import question

2009-09-24 Thread BareFeet
On 25/09/2009, at 7:47 AM, Jay A. Kreibich wrote:

> On Thu, Sep 24, 2009 at 09:12:20PM +0100, Simon Slavin scratched on  
> the wall:
>
>> The .import command does not handle quoted fields correctly, as has
>> recently been stated on this list.
>
>  I think it would be more fair to say that the .import command has
>  chosen not to support quoted fields.

>  The bigger issue is that CSV isn't really a format, but more of a
>  loose idea.  Yes, many systems that use CSV choose to assign meaning
>  to double quotations, but my first question to that is, "How do you  
> put
>  a double-quote into a value?"  Is it \" in a C-style escape, or maybe
>  double characters ("") like SQL?  If the answer is \", why not just
>  use \, in the first place?
>
>  There are no answers to these questions because there is no standard.

I see this said occasionally as a discussion on theory, but I  
disagree. In reality, in the thousands of CSV files I've dealt with  
over the years, they all follow the same standard:

1. Rows are delimited by a new line (return and/or line feed).
2. Columns are delimited by a comma.
3. "Quoted text" is treated as one value item, including any commas or  
new lines within it.
4. A double quote "" is used to put a quote within quotes.

That's it. Everything I've seen uses this. Some don't need delimiters  
in values, so they don't need quotes, but the encompassing  
specification works for all cases.

It's not that big a deal for SQLite to support it, so it should.

Tom
BareFeet

  --
Comparison of SQLite GUI applications:
http://www.tandb.com.au/sqlite/compare/?ml

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


Re: [sqlite] Sqlite profiler

2009-09-24 Thread George Bills
On 09/23/2009 11:16 PM, mcnamaragio wrote:
> Hello,
>
> Would anyone be interested in sqlite profiler? If yes what features would
> you expect from it?
>
> Thank you.
>
Yes, I would be interested. A high level breakdown of what SQLite is 
doing, and the time it's taking to do it would be useful for me - e.g. 
"finding appropriate rows from index, 3.123 seconds, grouping by rows 
and summing column, 2.456 seconds, ordering column by that sum, 2.987 
seconds, taking top 10 rows, 0.123 seconds, joining to table B, 0.927 
seconds" would be kind of what I'd be hoping for.

As for features, I wouldn't want much beyond the above. It wouldn't have 
to be graphical, or need to attach to a running query / SQLite session 
or anything like that for it to be useful to me.

I can probably find most of the "what is SQLite doing" info by looking 
at the "EXPLAIN" output, but so far I haven't put any effort into 
learning the opcodes. It seems like that output is a little more 
low-level than what I'd really want, and it doesn't give me the running 
time of each phase. Not to say that it isn't useful, but a profiler that 
fits somewhere in between "EXPLAIN" and "EXPLAIN QUERY PLAN" would be 
great for my needs.

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


Re: [sqlite] sqlite3_column_type bad value

2009-09-24 Thread Igor Tandetnik
Sebastian Bermudez wrote:
> sqlite3_open
> sqlite3_prepare ( "select * from t1" )
> get sqlite3_column_count(stmt)
> for 1 to colcount
>   sqlite3_column_type(stmt,index)   "always return 5"
> next

You need to call sqlite3_step first. sqlite3_column_type examines actual 
data in an actual row, but you haven't fetched any rows yet. Perhaps you 
meant to use sqlite3_column_decltype[16] ?

Also, columns are numbered from 0. You might be thinking about 
parameters (sqlite3_bind_*) which are numbered from 1.

Igor Tandetnik 



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


[sqlite] Ok. I found the error

2009-09-24 Thread Sebastian Bermudez
i can't call sqlite3_column_type before sqlite3_step !!
from sqlite.org:

"...If the SQL statement does not currently point to a valid row, or if the 
column index is out of range, the result is undefined. These routines may only 
be called when the most recent call to sqlite3_step() has returned SQLITE_ROW 
and neither sqlite3_reset() nor sqlite3_finalize() have been called 
subsequently..."


  Yahoo! Cocina

Encontra las mejores recetas con Yahoo! Cocina.


http://ar.mujer.yahoo.com/cocina/
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] sqlite3_column_type bad value

2009-09-24 Thread Sebastian Bermudez
i have 1 table:
create table t1 ( id integer not null primary key, descri text )

then i exec... "SELECT * FROM t1" 

when i get the column type... with [ sqlite3_column_type(stmt,index); ] 
i get always (int)5 = SQLITE_NULL

every else is correct !, i have the correct row count, field count; values in 
each row/columns

i do:
sqlite3_open
sqlite3_prepare ( "select * from t1" )
get sqlite3_column_count(stmt)
for 1 to colcount
   sqlite3_column_type(stmt,index)   "always return 5"
next
while (sqlite3_step=SQLITE_ROW)
fetch & save
wend
sqlite3_finalize




  Yahoo! Cocina

Encontra las mejores recetas con Yahoo! Cocina.


http://ar.mujer.yahoo.com/cocina/
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Sqlite reading all column data on selects.

2009-09-24 Thread Wolfgang Enzinger
Am Thu, 24 Sep 2009 14:18:33 -0400 schrieb D. Richard Hipp:

> When autovacuum=FULL or autovacuum=INCREMENTAL and SQLite needs to  
> seek to the end of a long chain of overflow pages, it attempts to use  
> the "pointer map pages" that are available in these modes to locate  
> the pages without actually reading the prior pages from the disk.  Key  
> word:  "attempts".  There is no guarantee of success.  But if the  
> database is not too badly fragmented, it will usually succeed.
> 
> When autovacuum=OFF, then pointer map pages are not availble and  
> SQLite is compelled to read all prior pages when seeking to the end of  
> an overflow chain.

That's interesting. So that means that if I create and fill an SQLite
database that is intended for later read-only access, I get an additional
performance boost with autovacuum=OFF as long as the database is created
and filled with data, and lateron I switch to autovacuum=FULL (or
INCREMENTAL) when I'm done? I.e. the latest after an explicit VACUUM when
I'm finished writing to the database, there would be no fragmentation
present, and read access would be perfectly optimized with any autovacuum
pragma other than OFF?

Thanks,
Wolfgang

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


Re: [sqlite] Tedious CSV import question

2009-09-24 Thread Petite Abeille

On Sep 24, 2009, at 11:47 PM, Jay A. Kreibich wrote:

> The bigger issue is that CSV isn't really a format, but more of a  
> loose idea.

Right, that said, sticking to RFC 4180 is not such a bad bet:
Common Format and MIME Type for Comma-Separated Values (CSV) Files
http://www.rfc-editor.org/rfc/rfc4180.txt

At least, you can always point people back to some kind of  
specification :)

My 2¢.

Cheers,

--
PA.

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


Re: [sqlite] Tedious CSV import question

2009-09-24 Thread Jay A. Kreibich
On Thu, Sep 24, 2009 at 09:12:20PM +0100, Simon Slavin scratched on the wall:

> The .import command does not handle quoted fields correctly, as has  
> recently been stated on this list.  

  I think it would be more fair to say that the .import command has
  chosen not to support quoted fields.  There is a big difference
  between not doing something and not doing something correctly.

  The bigger issue is that CSV isn't really a format, but more of a
  loose idea.  Yes, many systems that use CSV choose to assign meaning
  to double quotations, but my first question to that is, "How do you put
  a double-quote into a value?"  Is it \" in a C-style escape, or maybe
  double characters ("") like SQL?  If the answer is \", why not just
  use \, in the first place?

  There are no answers to these questions because there is no standard.
  You can't even use the modern defacto of asking, "What does Microsoft
  do?"  Different versions of Excel (nevermind different products) have
  different answers to some of these questions.  Heck, IIRC, there are
  cases when the *same* version of Excel on different platforms has 
  different answers.

  It is a hard problem, but I suppose the real answer-- one that has
  been around since mainframes started to spit out CSV files-- is you
  need to either A) avoid CSV files, B) don't use commas and accept you
  can't put your deliminator into values, or C) assume you must
  massage the data if you're moving CSV files from product one to
  product two.

  But blaming the product is kind of pointless because their all
  different.  You might as well blame whatever exported the data for
  using the non-standard quote extension to CSV.

   -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


[sqlite] Perl DBI/Sqlite Attach too much memory

2009-09-24 Thread John Lynch
Sqlite Users,

I am using sqliute user for a very large customer database.  I have 3
seperate DB files with a table in each file.  The files are cust,acct, and
web.

Each DB table has  ~ 200 Million Rows.  When I attach web and acct to cust
with perl DBI/DBD::Sqlite the process runs out of memory on windows (2G
32bit process limit).  The memory usage grows out of control while querying
all table joined together via the attach.

When I used a flattened table of the same data (ie create table as select *
from ...) via same attach to create the flattened table.  I have no
problems.


Any ideas on how to reduce the memory consumption when using attach?

Thank You

-- 
--
John Lynch
(217) 953-0557
johntly...@gmail.com
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Tedious CSV import question

2009-09-24 Thread Jimmy Verner
I had a lot of trouble with trying to import into SQL Manager from csv  
files.  Per some earlier advice, I began inputting through the console  
instead.  But I did figure out a way to cut down on the time.  I've  
been making cookie-cutter iPhone apps (a series of rules of legal  
procedure where the rules are in a sqlite database) so what I did was  
make a template of sorts.  In the left column is the INSERT INTO etc.  
In the middle column is the text I wish to insert. In the right column  
is the ');  When finished, I collapsed the table (plus I had to get  
rid of unwanted returns), then copied the whole thing and pasted it  
into the input box (or whatever it's called) on the console.  Works  
like a charm.  Then I look for error messages and fix things until  
there are no more errors. For the next app, I tinker with the template  
to make any changes required for the new data, then paste the new data  
into the middle column and off we go again.


I've attached a file with a few rows so you can see what I'm talking  
about.


Jimmy Verner
www.vernerlegal.com





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


Re: [sqlite] Sqlite profiler

2009-09-24 Thread mcnamaragio

I am thinking about developing a profiler but I am at a very early stage. I
have only ideas and nothing more yet. Before I start actual coding I would
like to know if anyone is interested in it as it will motivate me if I know
that people will benefit from the tool.

I am not sure whether I will be able to capture all the information but I
hope it will be a useful tool.

Thank you for sharing your opinion :)


TeDe wrote:
> 
> mcnamaragio schrieb:
>> Hello,
>>
>> Would anyone be interested in sqlite profiler? If yes what features would
>> you expect from it?
>>
>> Thank you. 
>>   
> If you mean, that every sub-query and its execution-time is displayed:
> yes, definitely! I would even pay money for it.
> 
> Features I would expect:
> - execution-time of every sub-query
> - records affected by every where-clause
> - indexes used
> - maybe a small graphical interface?
> - tabbed interface to compare different versions of a query during
> optimization
> 
> What are your plans?
> 
> Best Regards,
> 
> Thomas
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Sqlite-profiler-tp25531129p25586644.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] Tedious CSV import question

2009-09-24 Thread Fred Williams
Try this:

http://sqliteadmin.orbmu2k.de/

Works great for me.

Fred

-Original Message-
From: sqlite-users-boun...@sqlite.org
[mailto:sqlite-users-boun...@sqlite.org]on Behalf Of J Glassy
Sent: Thursday, September 24, 2009 3:16 PM
To: General Discussion of SQLite Database
Subject: Re: [sqlite] Tedious CSV import question


On c.Mundi's CSV inquiry,
  One way I (interactively) address the need to import CSV data into sqlite
databases is
to use Mrinal Kant's SQL Manager add-in. This offers what I believe are more
robust facilities for performing this type of bulk import. I'm not sure if
SQL Manager is an option for you, but give it a try if you can get by
without a strictly console level scripted solution.

joe

On Thu, Sep 24, 2009 at 2:12 PM, Simon Slavin
wrote:

>
> On 24 Sep 2009, at 8:37pm, C. Mundi wrote:
>
> > Happily, sqlite has a very nice .output mode for CSV.  It correctly
> > double-quotes fields when they contain a space or a comma, and it
> > correctly
> > 'escapes' double-quote literals as "".  Great!  I need to go the
> > other way.
> >
> > I don't see an inverse .import mode in sqlite to handle the completely
> > general CSV syntax.  As anyone who has ever tried knows, parsing
> > compliant
> > CSV is a lot harder than writing compliant CSV.
>
> Sorry, but you didn't miss anything, no such facility exists.
> The .import command does not handle quoted fields correctly, as has
> recently been stated on this list.  Some third-party tools do it fine
> but if you want to import your particular file you'll have to tweak
> your file so that whatever you're using as a separator never appears
> inside a field.
>
> Simon.
>
>
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>

Joe Glassy
Research Analyst/Programmer
University of Montana NSF EPSCoR Program
Davidson Honors College Room 013
Missoula, MT 59812
___
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] Tedious CSV import question

2009-09-24 Thread J Glassy
On c.Mundi's CSV inquiry,
  One way I (interactively) address the need to import CSV data into sqlite
databases is
to use Mrinal Kant's SQL Manager add-in. This offers what I believe are more
robust facilities for performing this type of bulk import. I'm not sure if
SQL Manager is an option for you, but give it a try if you can get by
without a strictly console level scripted solution.

joe

On Thu, Sep 24, 2009 at 2:12 PM, Simon Slavin
wrote:

>
> On 24 Sep 2009, at 8:37pm, C. Mundi wrote:
>
> > Happily, sqlite has a very nice .output mode for CSV.  It correctly
> > double-quotes fields when they contain a space or a comma, and it
> > correctly
> > 'escapes' double-quote literals as "".  Great!  I need to go the
> > other way.
> >
> > I don't see an inverse .import mode in sqlite to handle the completely
> > general CSV syntax.  As anyone who has ever tried knows, parsing
> > compliant
> > CSV is a lot harder than writing compliant CSV.
>
> Sorry, but you didn't miss anything, no such facility exists.
> The .import command does not handle quoted fields correctly, as has
> recently been stated on this list.  Some third-party tools do it fine
> but if you want to import your particular file you'll have to tweak
> your file so that whatever you're using as a separator never appears
> inside a field.
>
> Simon.
>
>
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>

Joe Glassy
Research Analyst/Programmer
University of Montana NSF EPSCoR Program
Davidson Honors College Room 013
Missoula, MT 59812
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Tedious CSV import question

2009-09-24 Thread Simon Slavin

On 24 Sep 2009, at 8:37pm, C. Mundi wrote:

> Happily, sqlite has a very nice .output mode for CSV.  It correctly
> double-quotes fields when they contain a space or a comma, and it  
> correctly
> 'escapes' double-quote literals as "".  Great!  I need to go the  
> other way.
>
> I don't see an inverse .import mode in sqlite to handle the completely
> general CSV syntax.  As anyone who has ever tried knows, parsing  
> compliant
> CSV is a lot harder than writing compliant CSV.

Sorry, but you didn't miss anything, no such facility exists.   
The .import command does not handle quoted fields correctly, as has  
recently been stated on this list.  Some third-party tools do it fine  
but if you want to import your particular file you'll have to tweak  
your file so that whatever you're using as a separator never appears  
inside a field.

Simon.


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


Re: [sqlite] Tedious CSV import question

2009-09-24 Thread Wilson, Ronald
Sadly, the sqlite3 command line does not handle quoted fields when importing 
CSV very well at all.  Commas inside quotes get treated as column separators, 
and newlines inside quotes get treated as row separators.  I had this problem 
earlier this year and ended up using excel to create insert statements.

I don't recall this feature being fixed since then; correct me if I'm wrong.  I 
haven't had time to fix it myself either, so I don't complain.

RW

Ron Wilson, Engineering Project Lead
(o) 434.455.6453, (m) 434.851.1612, www.harris.com

HARRIS CORPORATION   |   RF Communications Division 
assuredcommunications(tm)


> -Original Message-
> From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-
> boun...@sqlite.org] On Behalf Of C. Mundi
> Sent: Thursday, September 24, 2009 3:37 PM
> To: sqlite-users@sqlite.org
> Subject: [sqlite] Tedious CSV import question
> 
> 
> Hi.  I have scanned the list archives and Googled.  I may have missed
> something, but what I found was not sufficiently general or robust for
> my
> needs.
> 
> Happily, sqlite has a very nice .output mode for CSV.  It correctly
> double-quotes fields when they contain a space or a comma, and it
> correctly
> 'escapes' double-quote literals as "".  Great!  I need to go the other
> way.
> 
> I don't see an inverse .import mode in sqlite to handle the completely
> general CSV syntax.  As anyone who has ever tried knows, parsing
> compliant
> CSV is a lot harder than writing compliant CSV.
> 
> I'm hoping someone will (please) tell me I missed something in the
> sqlite
> docs.  Otherwise, I guess I'll be using python's csv module to turn my
> CSV
> file into SQL insert statements.  This is likely to be an infequent
> task,
> but it has to be done perfectly.  So if someone knows of a command-line
> tool
> to turn CSV into SQL inserts, I would appreciate that too.
> 
> Thanks,
> Carlos
> ___
> 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] Tedious CSV import question

2009-09-24 Thread C. Mundi
Hi.  I have scanned the list archives and Googled.  I may have missed
something, but what I found was not sufficiently general or robust for my
needs.

Happily, sqlite has a very nice .output mode for CSV.  It correctly
double-quotes fields when they contain a space or a comma, and it correctly
'escapes' double-quote literals as "".  Great!  I need to go the other way.

I don't see an inverse .import mode in sqlite to handle the completely
general CSV syntax.  As anyone who has ever tried knows, parsing compliant
CSV is a lot harder than writing compliant CSV.

I'm hoping someone will (please) tell me I missed something in the sqlite
docs.  Otherwise, I guess I'll be using python's csv module to turn my CSV
file into SQL insert statements.  This is likely to be an infequent task,
but it has to be done perfectly.  So if someone knows of a command-line tool
to turn CSV into SQL inserts, I would appreciate that too.

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


Re: [sqlite] Sqlite reading all column data on selects.

2009-09-24 Thread D. Richard Hipp

On Sep 24, 2009, at 2:09 PM, Martin Pfeifle wrote:

> Hi Richard,
>
> assume I have a table mytable (id, blob1,blob2,blob3,blob4)
> where each blob extends over several pages.
>
> Then I do the following SQL command:
> select blob4 from mytable where id = 4711
>
> Do I understand you correctly that in the case autuvacuum =true,
> the pages covered by blob1 to blob3 are not read from disk,
> whereas in the case autovaccum=false they are also read from disk  
> into main memory?
>


When autovacuum=FULL or autovacuum=INCREMENTAL and SQLite needs to  
seek to the end of a long chain of overflow pages, it attempts to use  
the "pointer map pages" that are available in these modes to locate  
the pages without actually reading the prior pages from the disk.  Key  
word:  "attempts".  There is no guarantee of success.  But if the  
database is not too badly fragmented, it will usually succeed.

When autovacuum=OFF, then pointer map pages are not availble and  
SQLite is compelled to read all prior pages when seeking to the end of  
an overflow chain.


D. Richard Hipp
d...@hwaci.com



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


Re: [sqlite] Sqlite reading all column data on selects.

2009-09-24 Thread Martin Pfeifle
Hi Richard,

assume I have a table mytable (id, blob1,blob2,blob3,blob4) 
where each blob extends over several pages.

Then I do the following SQL command:
select blob4 from mytable where id = 4711

Do I understand you correctly that in the case autuvacuum =true, 
the pages covered by blob1 to blob3 are not read from disk,
whereas in the case autovaccum=false they are also read from disk into main 
memory?

Martin 

 




Von: D. Richard Hipp 
An: General Discussion of SQLite Database 
Gesendet: Donnerstag, den 24. September 2009, 14:58:16 Uhr
Betreff: Re: [sqlite] Sqlite reading all column data on selects.


On Sep 24, 2009, at 8:42 AM, Adam Panayis wrote:

> Hi, are there plans to stop sqlite3 from reading in all column data on
> specific select queries? i.e I would like sqlite to ONLY read column
> data for columns which are specified in the select and where clauses.

Short answer:  Already does that.

Long answer:  SQLite pulls content from the disk one page at a time.  
If all the data is on the same page (the common case) then all the  
data will always be read from disk.  There is no getting around that.  
If the row is large and does not fit on a single page, then SQLite  
strives to avoid reading any pages that are not actually needed.  That  
is already implemented.  Because of the file format, sometimes earlier  
pages must be read in order to find the location of later pages.  In  
other cases (when you have autovacuum set) SQLite is able to guess the  
location of later pages without having to read earlier pages.  SQLite  
never reads pages that follow what is needed.

Once the necessary pages are in memory, SQLite only looks at the  
specific parts of a row that are requested.  Unrequested columns are  
never extracted or decoded from the raw row data.

D. Richard Hipp
d...@hwaci.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


Re: [sqlite] SQLite database on a certain high-performance "SSD"

2009-09-24 Thread Kosenko Max


Mark Parker-4 wrote:
> This isn't an "SSD". It's connected directly to the PCI Express bus, and 
> "low cost" it certainly is NOT. It's much more valuable than the server
> it's plugged into.

Check page size. It might be less than cluster of your ioExtreme. You should
also think about actually turning off filesystem cache on that file (with
increase of sqlite in-memory page cache) and that can require small
adjustments in SQLite sources for you.

-
Best Regards.
Max Kosenko.
-- 
View this message in context: 
http://www.nabble.com/SQLite-database-on-a-certain-high-performance-%22SSD%22-tp25550787p25574692.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] Sqlite reading all column data on selects.

2009-09-24 Thread D. Richard Hipp

On Sep 24, 2009, at 8:42 AM, Adam Panayis wrote:

> Hi, are there plans to stop sqlite3 from reading in all column data on
> specific select queries? i.e I would like sqlite to ONLY read column
> data for columns which are specified in the select and where clauses.

Short answer:  Already does that.

Long answer:  SQLite pulls content from the disk one page at a time.   
If all the data is on the same page (the common case) then all the  
data will always be read from disk.  There is no getting around that.   
If the row is large and does not fit on a single page, then SQLite  
strives to avoid reading any pages that are not actually needed.  That  
is already implemented.  Because of the file format, sometimes earlier  
pages must be read in order to find the location of later pages.  In  
other cases (when you have autovacuum set) SQLite is able to guess the  
location of later pages without having to read earlier pages.   SQLite  
never reads pages that follow what is needed.

Once the necessary pages are in memory, SQLite only looks at the  
specific parts of a row that are requested.  Unrequested columns are  
never extracted or decoded from the raw row data.

D. Richard Hipp
d...@hwaci.com



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


Re: [sqlite] Sqlite reading all column data on selects.

2009-09-24 Thread Igor Tandetnik
Adam Panayis wrote:
> Hi, are there plans to stop sqlite3 from reading in all column data on
> specific select queries? i.e I would like sqlite to ONLY read column
> data for columns which are specified in the select and where clauses.

What do you mean by "reading in" here? I'm not sure I understand 
precisely what behavior you find objectionable.

Igor Tandetnik 



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


Re: [sqlite] Sqlite reading all column data on selects.

2009-09-24 Thread Griggs, Donald
Hello, Adam,

Regarding: "... are there plans to stop sqlite3 from reading in all
column data on specific select queries? i.e I would like sqlite to ONLY
read column data for columns which are specified in the select and where
clauses."

I'm no sqlite expert, and moreover I'm not sure I understand your
question properly.  Are you wanting to prevent sqlite from transferring
data columns from disk when those columns are not needed?

If so, I don't think that's generally feasible.  You might want to look
at sqlite's (and other database system's) architechture.   Sqlite will
instruct the operating system to read *pages* that it needs to complete
your requests.

That being said, you *can* sometimes improve performance by locating
less-used columns later in your table definition (i.e., "to the right
of" the more-used columns).  Even better, you can place large blob-ish
fields into separate tables, along with an indexing identifier, in the
hope that these pages will be read only when required.

What problem are you attempting to solve?

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


[sqlite] FTS3 phantom token?...

2009-09-24 Thread Shopsland gmail
Hi,
Mining my fts3 table stemmed with Porter I found that there is a 'phantom'
token indexed by fts3.

When I issue this query:

   select title from fts_news where fts_news match 'ined'

I got about 700 rows that do not have the word 'ined' in any form (ie: ined
or inedible).

If I issue those queries:

select title from fts_news where title like 'ined%'
select title from fts_news where title like '% ined%'

Not a single row is returned.

I have optimized the fts3 index with:

SELECT optimize(fts_news) FROM fts_news LIMIT 1;

And did a vacuum but the phantom token 'ined' is not deleted.

Can anyone confirm this?

Jochi Martínez
www.bfreenews.com
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Sqlite reading all column data on selects.

2009-09-24 Thread Adam Panayis
Hi, are there plans to stop sqlite3 from reading in all column data on 
specific select queries? i.e I would like sqlite to ONLY read column 
data for columns which are specified in the select and where clauses.

Thanks.
Adam.

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


Re: [sqlite] SQLite Suitability for Shopping Cart

2009-09-24 Thread CityDev

Thanks for that Sebastian. 

It does however surprise me. I believe Access Jet handles simultaneous
activities. Indeed I've got a feeling it does row-locking rather than
page-locking. It's odd that SQLite has such a limitation. Anyway, you've
saved me a lot of heartache.
-- 
View this message in context: 
http://www.nabble.com/SQLite-Suitability-for-Shopping-Cart-tp25530589p25562183.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] Sqlite profiler

2009-09-24 Thread Jim "Jed" Dodgen
how would your profiler differ from "explain"?

http://sqlite.org/lang_explain.html

On Wed, Sep 23, 2009 at 6:32 AM, Christian Schwarz
 wrote:
>> Maybe, what is it?
>
> http://en.wikipedia.org/wiki/Profiling_(computer_programming)
>
> Cheers, Christian
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>



-- 
Jim "Jed" Dodgen
j...@dodgen.us
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Importing data into SQLite

2009-09-24 Thread Dan Bishop
T wrote:
>
> You can use the sqlite binary to import data from a CSV file - if you do it
> that way you have to make sure that your data fields in the SQLite database
> match exactly in order the data in the CSV file. That's been my experience.
> The other way is to do it programmatically (Java, C++, etc). The advantage
> of that is you have control over the data import. Though the sqlite binary
> does an excellent job of importing data, it might be better to use the
> latter option if you want more control over the data. It's not a difficult
> job to do.
>
>
> Could you please explain how does it go by doing other way-programmatically
> in c++?
> I have installed sqlite and then i have found somewhere information that i
> also need a sqlite++ wrapper to be able to use sqlite trought c++. so, i
> have installed both, but i dont dont know how to connect sqlite and sqlite++
> to each other, if i have to do it, at all.
> I'm really new to all this, but i have an asignment to copy datas from c++
> into sqlite and i dont know even how to start..
> If someone could just tell me in short steps what do i need, then i will
> find somehow solutions for  each step..
>
> Thank you very much!
>   
(1) Parse the CSV data into a two-dimensional array.
(2) Get the column headers from the first row.
(3) Scan through each column to see if its data can be converted to 
INTEGER or REAL.  Based on this, choose a type affinity for the column.
(4) From the information determined in steps (2) and (3), build and 
execute a CREATE TABLE statement.
(5) BEGIN TRANSACTION
(6) Build and execute an INSERT statement for each row in the table.
(7) COMMIT

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


Re: [sqlite] SQL Lite date / time functions

2009-09-24 Thread Alexey Pechnikov
Hello!

On Thursday 24 September 2009 05:54:12 Dan Bishop wrote:
> > Can you add this note to documentation? This is very speculate question.
> > Especially because internal SQLite representation of julianday was chanded
> > some times ago.
> It's not a date-specific issue; the same thing occurs with ordinary numbers.
> 
> sqlite> select (1.0/49)*49 = 1.0;
> 0

Yes it is, but for ordinary numbers is not useful to check like this
select (1.0/50)*50 = 1.0;
1

The equality check of midnights in julianday format is more common task. I see
this question in the mail list every week.

Best regards, Alexey Pechnikov.
http://pechnikov.tel/
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Importing data into SQLite

2009-09-24 Thread TTTTT



You can use the sqlite binary to import data from a CSV file - if you do it
that way you have to make sure that your data fields in the SQLite database
match exactly in order the data in the CSV file. That's been my experience.
The other way is to do it programmatically (Java, C++, etc). The advantage
of that is you have control over the data import. Though the sqlite binary
does an excellent job of importing data, it might be better to use the
latter option if you want more control over the data. It's not a difficult
job to do.


Could you please explain how does it go by doing other way-programmatically
in c++?
I have installed sqlite and then i have found somewhere information that i
also need a sqlite++ wrapper to be able to use sqlite trought c++. so, i
have installed both, but i dont dont know how to connect sqlite and sqlite++
to each other, if i have to do it, at all.
I'm really new to all this, but i have an asignment to copy datas from c++
into sqlite and i dont know even how to start..
If someone could just tell me in short steps what do i need, then i will
find somehow solutions for  each step..

Thank you very much!
-- 
View this message in context: 
http://www.nabble.com/Importing-data-into-SQLite-tp25224025p25538942.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