-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 22/09/12 13:41, Keith Medcalf wrote:
> Take a look at the apsw (Another Python SQLite Wrapper) shell which has
> an .autoimport command that may do what you want.

Thanks for pointing out APSW (I'm the author).  It is only necessary to
use the APSW shell to do the autoimport - after that you can use the
database anywhere. Here is the detailed help information for the
autoimport command:

=== 8< ===

The import command requires that you precisely pre-setup the table and
schema, and set the data separators (eg commas or tabs).  In many cases
this information can be automatically deduced from the file contents
which is what this command does.  There must be at least two columns and
two rows.

If the table is not specified then the basename of the file will be
used.

Additionally the type of the contents of each column is also deduced -
for example if it is a number or date.  Empty values are turned into
nulls.  Dates are normalized into YYYY-MM-DD format and DateTime are
normalized into ISO8601 format to allow easy sorting and searching.  4
digit years must be used to detect dates.  US (swapped day and month)
versus rest of the world is also detected providing there is at least
one value that resolves the ambiguity.

Care is taken to ensure that columns looking like numbers are only
treated as numbers if they do not have unnecessary leading zeroes or
plus signs.  This is to avoid treating phone numbers and similar number
like strings as integers.

This command can take quite some time on large files as they are
effectively imported twice.  The first time is to determine the format
and the types for each column while the second pass actually imports the
data.

=== 8< ===

Roger
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iEYEARECAAYFAlBeMjkACgkQmOOfHg372QQ7hwCeJgqwYFzG7ZK1fA+a/FWJVGo0
IiMAnRzavbeacm+aAkYvDfZHQiNY+NjD
=Xybr
-----END PGP SIGNATURE-----
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to