|
4 | 4 | """
|
5 | 5 | from __future__ import print_function, division
|
6 | 6 | from datetime import datetime, date, timedelta
|
| 7 | + |
7 | 8 | import warnings
|
8 |
| -from pandas.compat import lzip, map, zip, raise_with_traceback, string_types |
| 9 | +import itertools |
9 | 10 | import numpy as np
|
10 | 11 |
|
11 | 12 | import pandas.core.common as com
|
| 13 | +from pandas.compat import lzip, map, zip, raise_with_traceback, string_types |
12 | 14 | from pandas.core.api import DataFrame
|
13 | 15 | from pandas.core.base import PandasObject
|
14 | 16 | from pandas.tseries.tools import to_datetime
|
@@ -432,7 +434,6 @@ def insert(self):
|
432 | 434 | data = dict((k, self.maybe_asscalar(v))
|
433 | 435 | for k, v in t[1].iteritems())
|
434 | 436 | data_list.append(data)
|
435 |
| - #self.pd_sql.execute(ins, **data) |
436 | 437 | self.pd_sql.execute(ins, data_list)
|
437 | 438 |
|
438 | 439 | def read(self, coerce_float=True, parse_dates=None, columns=None):
|
@@ -548,30 +549,22 @@ def _harmonize_columns(self, parse_dates=None):
|
548 | 549 | def _sqlalchemy_type(self, arr_or_dtype):
|
549 | 550 | from sqlalchemy.types import Integer, Float, Text, Boolean, DateTime, Date, Interval
|
550 | 551 |
|
551 |
| - if isinstance(arr_or_dtype, np.dtype): |
552 |
| - tipo = arr_or_dtype |
553 |
| - elif isinstance(arr_or_dtype, type): |
554 |
| - tipo = np.dtype(arr_or_dtype) |
555 |
| - else: |
556 |
| - tipo = arr_or_dtype.dtype |
557 |
| - |
558 | 552 | if arr_or_dtype is date:
|
559 | 553 | return Date
|
560 | 554 | if com.is_datetime64_dtype(arr_or_dtype):
|
561 | 555 | try:
|
562 | 556 | tz = arr_or_dtype.tzinfo
|
563 | 557 | return DateTime(timezone=True)
|
564 | 558 | except:
|
565 |
| - print('no tzinfo') |
566 | 559 | return DateTime
|
567 | 560 | if com.is_timedelta64_dtype(arr_or_dtype):
|
568 | 561 | return Interval
|
569 |
| - if com.is_float_dtype(arr_or_dtype): |
| 562 | + elif com.is_float_dtype(arr_or_dtype): |
570 | 563 | return Float
|
571 |
| - if com.is_integer_dtype(arr_or_dtype): |
| 564 | + elif com.is_integer_dtype(arr_or_dtype): |
572 | 565 | # TODO: Refine integer size.
|
573 | 566 | return Integer
|
574 |
| - if isinstance(tipo, np.bool_): |
| 567 | + elif com.is_bool(arr_or_dtype): |
575 | 568 | return Boolean
|
576 | 569 | return Text
|
577 | 570 |
|
@@ -769,8 +762,6 @@ def insert(self):
|
769 | 762 | data = [self.maybe_asscalar(v) for v in r[1].values]
|
770 | 763 | if self.index is not None:
|
771 | 764 | data.insert(0, self.maybe_asscalar(r[0]))
|
772 |
| - print(type(data[2])) |
773 |
| - print(type(r[0])) |
774 | 765 | cur.execute(ins, tuple(data))
|
775 | 766 | cur.close()
|
776 | 767 |
|
|
0 commit comments