Continue to refactor the import for "dataset"

This commit is contained in:
Friedrich Lindenberg 2013-04-01 17:29:30 +02:00
parent ef535a4855
commit 22255c3894
3 changed files with 16 additions and 11 deletions

View File

@ -0,0 +1,13 @@
def resultiter(rp):
""" SQLAlchemy ResultProxies are not iterable to get a
list of dictionaries. This is to wrap them. """
keys = rp.keys()
while True:
row = rp.fetchone()
if row is None:
break
yield dict(zip(keys, row))

View File

@ -2,19 +2,11 @@ import logging
from itertools import count
from sqlalchemy.sql import expression, and_
from sqlaload.schema import _ensure_columns, get_table
from dataset.schema import _ensure_columns, get_table
from dataset.persistence.util import resultiter
log = logging.getLogger(__name__)
def resultiter(rp):
""" SQLAlchemy ResultProxies are not iterable to get a
list of dictionaries. This is to wrap them. """
keys = rp.keys()
while True:
row = rp.fetchone()
if row is None:
break
yield dict(zip(keys, row))
def find_one(engine, table, **kw):
table = get_table(engine, table)

View File

@ -1,7 +1,7 @@
import unittest
from datetime import datetime
from sqlaload import *
from dataset import *
TEST_DATA = [
{