self.operations = list()
for operation_data in data["operations"]:
param = {}
if "operation_id" in operation_data:
param["operation_id"] = operation_data["operation_id"]
else:
param["operation_id"] = None
if "status" in operation_data:
param["status"] = operation_data["status"]
else:
param["status"] = None
if "datetime" in operation_data:
param["datetime"] = datetime.strptime(str(operation_data["datetime"]).replace("T", " ").replace("Z", ""), '%Y-%m-%d %H:%M:%S')
else:
param["datetime"] = None
if "title" in operation_data:
param["title"] = operation_data["title"]
else:
param["title"] = None
if "pattern_id" in operation_data:
param["pattern_id"] = operation_data["pattern_id"]
else:
param["pattern_id"] = None
if "direction" in operation_data:
param["direction"] = operation_data["direction"]
else:
param["direction"] = None
if "amount" in operation_data:
param["amount"] = operation_data["amount"]
else:
param["amount"] = None
if "label" in operation_data:
param["label"] = operation_data["label"]
else:
param["label"] = None
if "type" in operation_data:
param["type"] = operation_data["type"]
else:
param["type"] = None
Traceback (most recent call last):
File "C:\Users\admin\PycharmProjects\pythonProject3\b.py", line 24, in <module>
history = client.operation_history(label='a1b2c3d4e5')
File "C:\Users\admin\PycharmProjects\pythonProject3\venv\lib\site-packages\yoomoney\client.py", line 44, in operation_history
return History(base_url=self.base_url,
File "C:\Users\admin\PycharmProjects\pythonProject3\venv\lib\site-packages\yoomoney\history\history.py", line 96, in __init__
for operation_data in data["operations"]:
TypeError: string indices must be integers
CREATE TABLE art (
id INTEGER PRIMARY KEY AUTOINCREMENT,
auth [VARCHAR TOPIC VARCHAR],
topic VARCHAR,
content TEXT
);
def user_exists(self, user_id):
with self.connection:
result = self.cursor.execute("Select * FROM 'users' WHERE 'user_id' = ?", (user_id,)).fetchall()
return bool(len(result))
def add_user(self, user_id):
with self.connection:
self.cursor.execute("INSERT INTO 'users' ('user_id') VALUES (?)", (user_id,))
<i> self.connection.commit()</i>
def user_money(self, user_id):
with self.connection:
result = self.cursor.execute("SELECT 'money' FROM 'users' WHERE 'user_id' = ?", (user_id,)).fetchmany(1)
return int(result[0][0])
def set_money(self, user_id, money):
with self.connection:
return self.cursor.execute("UPDATE 'users' SET 'money' = ? WHERE 'user_id' = ?", (money, user_id))
<i> self.connection.commit()</i>