[fix] tools:convert
This commit is contained in:
parent
ab35c2675b
commit
4a1d2425b8
1 changed files with 15 additions and 1 deletions
|
@ -87,10 +87,12 @@ def main(
|
|||
)
|
||||
)
|
||||
ids = {
|
||||
"calendars": 0,
|
||||
"local_resource": 0,
|
||||
"caldav_resource": 0,
|
||||
}
|
||||
for calendar in data["calendars"]:
|
||||
ids["calendars"] += 1
|
||||
if (calendar["object"]["kind"] == "concrete"):
|
||||
ids["local_resource"] += 1
|
||||
print(
|
||||
|
@ -149,13 +151,25 @@ def main(
|
|||
raise ValueError("invalid")
|
||||
print(
|
||||
string_coin(
|
||||
"INSERT INTO calendars(name,public,resource_id) VALUES ({{name}},{{public}},LAST_INSERT_ROWID());\n",
|
||||
"INSERT INTO calendars(id,name,public,resource_id) VALUES ({{id}},{{name}},{{public}},LAST_INSERT_ROWID());\n",
|
||||
{
|
||||
"id": sql_format(ids["calendars"]),
|
||||
"name": sql_format(calendar["object"]["data"]["name"]),
|
||||
"public": sql_format(not calendar["object"]["data"]["private"]),
|
||||
}
|
||||
)
|
||||
)
|
||||
for member in calendar["object"]["data"].get("users", []):
|
||||
print(
|
||||
string_coin(
|
||||
"INSERT INTO calendar_members(calendar_id,user_id,role) VALUES ({{calendar_id}},{{user_id}},{{role}});\n",
|
||||
{
|
||||
"calendar_id": sql_format(ids["calendars"]),
|
||||
"user_id": sql_format(member["id"]),
|
||||
"role": sql_format(member["role"]),
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
main()
|
||||
|
|
Loading…
Add table
Reference in a new issue