Repository: blaze/blaze

Issue:
SQL <- CSV loading errors pop up inappropriately
``` Python
In [1]: from blaze import *

In [2]: csv = resource('examples/data/iris.csv')

In [3]: sql = SQL('sqlite:///:memory:', 'tablename2', schema=csv.schema)

In [4]: into(sql, 'examples/data/iris.csv')
Windows native sqlite copy is not supported
Defaulting to sql.extend() method
Out[4]: <blaze.data.sql.SQL at 0x7f7fd0ceb290>
```

cc @cpcloud @quasiben 



Discussion:
looks like that was introduced in f2bafe2c

@mrocklin i think a changing of the error message is appropriate here

Agreed

Or having two

pr coming up

yep win32 should warn :memory: should not


Resolving patch:
diff --git a/blaze/data/__init__.py b/blaze/data/__init__.py
--- a/blaze/data/__init__.py
+++ b/blaze/data/__init__.py
@@ -10,4 +10,4 @@
 
 __all__ = ['CSV', 'Concat', 'DataDescriptor', 'HDF5', 'JSON', 'JSON_Streaming',
            'SQL', 'Stack', 'coerce', 'coerce_row_to_dict', 'coerce_to_ordered',
-           'date', 'datetime', 'discover', 'dshape', 'nd', 'time', 'Excel']
+           'discover', 'dshape', 'nd', 'Excel']
diff --git a/blaze/data/sql.py b/blaze/data/sql.py
--- a/blaze/data/sql.py
+++ b/blaze/data/sql.py
@@ -1,22 +1,19 @@
 from __future__ import (absolute_import, division, print_function,
                         unicode_literals)
 
-from datetime import date, datetime, time
-from decimal import Decimal
 import sys
+import warnings
 from dynd import nd
 import sqlalchemy as sql
 import sqlalchemy
 import datashape
 from datashape import dshape, var, Record, Option, isdimension
 from itertools import chain
-from toolz import first
+import subprocess
 
 from ..dispatch import dispatch
 from ..utils import partition_all
-from ..compatibility import basestring
 from .core import DataDescriptor
-from .utils import coerce_row_to_dict
 from ..compatibility import _inttypes, _strtypes
 from .csv import CSV
 
@@ -405,10 +402,11 @@ def retrieve_kwarg(term):
 
     #only works on OSX/Unix
     elif dbtype == 'sqlite':
-        import subprocess
-        if sys.platform == 'win32' or db == ":memory:":
-            print("Windows native sqlite copy is not supported")
-            print("Defaulting to sql.extend() method")
+        if db == ':memory:':
+            sql.extend(csv)
+        elif sys.platform == 'win32':
+            warnings.warn("Windows native sqlite copy is not supported\n"
+                          "Defaulting to sql.extend() method")
             sql.extend(csv)
         else:
             #only to be used when table isn't already created?
@@ -420,7 +418,7 @@ def retrieve_kwarg(term):
             copy_cmd = "(echo '.mode csv'; echo '.import {abspath} {tblname}';) | sqlite3 {db}"
             copy_cmd = copy_cmd.format(**copy_info)
 
-            ps = subprocess.Popen(copy_cmd,shell=True, stdout=subprocess.PIPE)
+            ps = subprocess.Popen(copy_cmd, shell=True, stdout=subprocess.PIPE)
             output = ps.stdout.read()
 
     elif dbtype == 'mysql':
diff --git a/blaze/sql.py b/blaze/sql.py
--- a/blaze/sql.py
+++ b/blaze/sql.py
@@ -1,11 +1,12 @@
 from __future__ import absolute_import, division, print_function
 
 from .compute.sql import select
-from .data.sql import SQL, dispatch, first
+from .data.sql import SQL, dispatch
 from .expr import Expr, TableExpr, Projection, Column, UnaryOp, BinOp, Join
 from .expr.scalar.core import Scalar
 from .compatibility import basestring
 from .api.resource import resource
+from toolz import first
 
 
 import sqlalchemy as sa


Test patch: