chrthomsen / pygrametl

Official repository for pygrametl - ETL programming in Python
http://pygrametl.org
BSD 2-Clause "Simplified" License
291 stars 41 forks source link

Issue on Dimension #7

Closed leojosefm closed 8 years ago

leojosefm commented 8 years ago

I'm getting below error for Dimension Code -

productDimension = Dimension(
    name='product',
    key='productid',
    attributes=['name', 'category', 'price'],
    lookupatts=['name'])

Error -

Traceback (most recent call last): File "petl_demo.py", line 19, in lookupatts=['name']) File "C:\Anaconda3\lib\site-packages\pygrametl\tables.py", line 189, in init (self.quote(key), name)) File "C:\Anaconda3\lib\site-packages\pygrametlinit.py", line 663, in execute self.__cursor.execute(stmt, arguments) TypeError: expecting a dictionary, sequence or keyword args

chrthomsen commented 8 years ago

Hello,

I cannot recreate that error. Do you get the error when you create the Dimension instance or when you use it (e.g., with insert(...) or ensure(...))? And which DB driver do you use?

Best regards, Christian Thomsen

leojosefm commented 8 years ago

Hi,

I'm getting that error when I create dimension instance. I'm connecting to oracle DB

conn_str=u'hr/hr@localhost:1521/PDBORCL'
conn= cx.connect(conn_str)
dw_conn=pygrametl.ConnectionWrapper(connection=conn)

I'm able to create fact table instance using below code -

factTable = FactTable(
    name='facttable',
    measures=['price'],
    keyrefs=['storeid', 'productid', 'dateid'])
chrthomsen commented 8 years ago

Hi,

Could you please try again with the new__init__.py that I just committed? I hope that solves the problem.

Best regards, Christian Thomsen

leojosefm commented 8 years ago

Hi,

Thank you so much Christian. It worked!! . I'm actually new to Python, without much experience to programming apart from some shell scripting.

Please can you let me know the fix?

On Thu, Oct 27, 2016 at 8:42 AM, Christian Thomsen <notifications@github.com

wrote:

Hi,

Could you please try again with the new init.py that I just committed? I hope that solves the problem.

Best regards, Christian Thomsen

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/chrthomsen/pygrametl/issues/7#issuecomment-256629980, or mute the thread https://github.com/notifications/unsubscribe-auth/AV-k9JjskMCyZb-cDIk2CEVpZra1kQz5ks5q4Jw1gaJpZM4Kfhv7 .

chrthomsen commented 8 years ago

Hi,

Good that it works. You can see the changes here: https://github.com/chrthomsen/pygrametl/commit/dd76903a6f49e35d7d8d1747bf0b2d5fe2beb99a In short, we sometimes passed a None value to the underlying cursor's execute method. Some PEP249 implementations accept that, others don't, so now we don't pass the None value anymore to be safe.

Best regards, Christian

P.S. You reported this for the Dimension class. Note that CachedDimension often will lead to much better performance.