1
シンプルなPython SQLAlchemy where()
ですが、このエラーで狂ってしまいます。それを理解できません。SQL Alchemy TypeError:予期せぬキーワード引数を持っています
In [1]: import sqlalchemy as sa
...: import pandas as pd
...:
...: import etl_utils as eu
In [2]: engine = eu.set_db('s','username',input('enter password:\t'),
...: sql_database_name='DBNAME')
In [3]: meta = sa.MetaData(engine)
...: meta.reflect()
...編集さは...
In [6]: tbl
Out[6]: Table('factSecurityPrices', MetaData(bind=Engine(mssql+pyodbc:///?odbc_connect=Driver={ODBC Driver 13 for SQL Server};Server=redacted)), Column('SecurityID_FK', INTEGER(), ForeignKey('dimSecurities.SecurityID_PK'), table=<factSecurityPrices>), Column('ImportInfoID_FK', INTEGER(), ForeignKey('dimImportInfo.ImportInfoID_PK'), table=<factSecurityPrices>), Column('PriceDate', DATETIME(), table=<factSecurityPrices>), Column('SecurityPrice', DECIMAL(precision=22, scale=4), table=<factSecurityPrices>), schema=None)
In [7]: tbl.update().where(ImportInfoID_FK=398).values(SecurityPrice=8.5)
Traceback (most recent call last):
File "<ipython-input-7-dfa9428585e6>", line 1, in <module>
tbl.update().where(ImportInfoID_FK=398).values(SecurityPrice=8.5)
TypeError: where() got an unexpected keyword argument 'ImportInfoID_FK'
はなぜ地球上で私が
kwarg
where()
にを渡すことはできません?オンラインのすべての例とドキュメントは、あなたができることを示しています!
編集:コメント欄で提案を使用してみました 、動作しませんでした:
In [8]: tbl.update().where(tbl.ImportInfoID_FK=398).values(SecurityPrice=8.5)
File "<ipython-input-8-53fb97b0906a>", line 1
tbl.update().where(tbl.ImportInfoID_FK=398).values(SecurityPrice=8.5)
^
SyntaxError: keyword can't be an expression
In [9]: tbl.update().where(tbl.c.ImportInfoID_FK=398).values(SecurityPrice=8.5)
File "<ipython-input-9-c1ceb5a2591f>", line 1
tbl.update().where(tbl.c.ImportInfoID_FK=398).values(SecurityPrice=8.5)
^
SyntaxError: keyword can't be an expression
キーワードは表現できません、私は質問を編集しました –
.values()は名前付き引数を使用しますが、where()メソッドはtbl.c.column_nameを使用します – Calumah
'=' where句を式に変換しますが、これは不正です。代わりに '=='を使用してください。 –