datasette-edit-schema 0.8a0__py3-none-any.whl → 0.8a2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of datasette-edit-schema might be problematic. Click here for more details.
- datasette_edit_schema/__init__.py +21 -14
- datasette_edit_schema/templates/edit_schema_database.html +1 -1
- datasette_edit_schema/templates/edit_schema_table.html +8 -8
- {datasette_edit_schema-0.8a0.dist-info → datasette_edit_schema-0.8a2.dist-info}/METADATA +2 -2
- {datasette_edit_schema-0.8a0.dist-info → datasette_edit_schema-0.8a2.dist-info}/RECORD +9 -9
- {datasette_edit_schema-0.8a0.dist-info → datasette_edit_schema-0.8a2.dist-info}/WHEEL +1 -1
- {datasette_edit_schema-0.8a0.dist-info → datasette_edit_schema-0.8a2.dist-info}/LICENSE +0 -0
- {datasette_edit_schema-0.8a0.dist-info → datasette_edit_schema-0.8a2.dist-info}/entry_points.txt +0 -0
- {datasette_edit_schema-0.8a0.dist-info → datasette_edit_schema-0.8a2.dist-info}/top_level.txt +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from datasette import hookimpl
|
|
2
2
|
from datasette.events import CreateTableEvent, AlterTableEvent, DropTableEvent
|
|
3
3
|
from datasette.utils.asgi import Response, NotFound, Forbidden
|
|
4
|
-
from datasette.utils import sqlite3
|
|
4
|
+
from datasette.utils import sqlite3, tilde_decode, tilde_encode
|
|
5
5
|
from urllib.parse import quote_plus, unquote_plus
|
|
6
6
|
import sqlite_utils
|
|
7
7
|
import textwrap
|
|
@@ -40,9 +40,10 @@ def table_actions(datasette, actor, database, table):
|
|
|
40
40
|
return [
|
|
41
41
|
{
|
|
42
42
|
"href": datasette.urls.path(
|
|
43
|
-
"/-/edit-schema/{}/{}".format(database,
|
|
43
|
+
"/-/edit-schema/{}/{}".format(database, tilde_encode(table))
|
|
44
44
|
),
|
|
45
45
|
"label": "Edit table schema",
|
|
46
|
+
"description": "Rename the table, add and remove columns...",
|
|
46
47
|
}
|
|
47
48
|
]
|
|
48
49
|
|
|
@@ -106,6 +107,7 @@ def database_actions(datasette, actor, database):
|
|
|
106
107
|
"/-/edit-schema/{}/-/create".format(database)
|
|
107
108
|
),
|
|
108
109
|
"label": "Create a table",
|
|
110
|
+
"description": "Define a new table with specified columns",
|
|
109
111
|
}
|
|
110
112
|
]
|
|
111
113
|
|
|
@@ -214,6 +216,7 @@ async def edit_schema_database(request, datasette):
|
|
|
214
216
|
{
|
|
215
217
|
"database": database,
|
|
216
218
|
"tables": tables,
|
|
219
|
+
"tilde_encode": tilde_encode,
|
|
217
220
|
},
|
|
218
221
|
request=request,
|
|
219
222
|
)
|
|
@@ -305,7 +308,7 @@ async def edit_schema_create_table(request, datasette):
|
|
|
305
308
|
|
|
306
309
|
|
|
307
310
|
async def edit_schema_table(request, datasette):
|
|
308
|
-
table =
|
|
311
|
+
table = tilde_decode(request.url_vars["table"])
|
|
309
312
|
databases = get_databases(datasette)
|
|
310
313
|
database_name = request.url_vars["database"]
|
|
311
314
|
|
|
@@ -546,16 +549,14 @@ async def edit_schema_table(request, datasette):
|
|
|
546
549
|
info["foreign_key"].other_column,
|
|
547
550
|
),
|
|
548
551
|
"value": "{}.{}".format(
|
|
549
|
-
info["foreign_key"].other_table,
|
|
550
|
-
info["foreign_key"].other_column,
|
|
552
|
+
tilde_encode(info["foreign_key"].other_table),
|
|
553
|
+
tilde_encode(info["foreign_key"].other_column),
|
|
551
554
|
),
|
|
552
555
|
"selected": True,
|
|
553
556
|
}
|
|
554
557
|
)
|
|
555
558
|
seen.add(
|
|
556
|
-
"
|
|
557
|
-
info["foreign_key"].other_table, info["foreign_key"].other_column
|
|
558
|
-
)
|
|
559
|
+
(info["foreign_key"].other_table, info["foreign_key"].other_column)
|
|
559
560
|
)
|
|
560
561
|
# Now add suggestions
|
|
561
562
|
for suggested_table, suggested_column in info["suggestions"]:
|
|
@@ -568,19 +569,24 @@ async def edit_schema_table(request, datasette):
|
|
|
568
569
|
"name": "{}.{} (suggested)".format(
|
|
569
570
|
suggested_table, suggested_column
|
|
570
571
|
),
|
|
571
|
-
"value": "{}.{}".format(
|
|
572
|
+
"value": "{}.{}".format(
|
|
573
|
+
tilde_encode(suggested_table),
|
|
574
|
+
tilde_encode(suggested_column),
|
|
575
|
+
),
|
|
572
576
|
"selected": False,
|
|
573
577
|
}
|
|
574
578
|
)
|
|
575
|
-
seen.add(
|
|
579
|
+
seen.add((suggested_table, suggested_column))
|
|
576
580
|
info["suggested"] = "{}.{}".format(suggested_table, suggested_column)
|
|
577
581
|
# And the rest
|
|
578
582
|
for rest_table, rest_column in info["options"]:
|
|
579
|
-
if
|
|
583
|
+
if (rest_table, rest_column) not in seen:
|
|
580
584
|
options.append(
|
|
581
585
|
{
|
|
582
586
|
"name": "{}.{}".format(rest_table, rest_column),
|
|
583
|
-
"value": "{}.{}".format(
|
|
587
|
+
"value": "{}.{}".format(
|
|
588
|
+
tilde_encode(rest_table), tilde_encode(rest_column)
|
|
589
|
+
),
|
|
584
590
|
"selected": False,
|
|
585
591
|
}
|
|
586
592
|
)
|
|
@@ -617,6 +623,7 @@ async def edit_schema_table(request, datasette):
|
|
|
617
623
|
"can_rename_table": await can_rename_table(
|
|
618
624
|
datasette, request.actor, database_name, table
|
|
619
625
|
),
|
|
626
|
+
"tilde_encode": tilde_encode,
|
|
620
627
|
},
|
|
621
628
|
request=request,
|
|
622
629
|
)
|
|
@@ -780,8 +787,8 @@ async def update_foreign_keys(request, datasette, database, table, formdata):
|
|
|
780
787
|
fks.append(
|
|
781
788
|
(
|
|
782
789
|
column,
|
|
783
|
-
split[0],
|
|
784
|
-
split[1],
|
|
790
|
+
tilde_decode(split[0]),
|
|
791
|
+
tilde_decode(split[1]),
|
|
785
792
|
)
|
|
786
793
|
)
|
|
787
794
|
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<h1>Edit tables in {{ database.name }}.db</h1>
|
|
11
11
|
|
|
12
12
|
{% for table in tables %}
|
|
13
|
-
<h2><a href="/-/edit-schema/{{ database.name|quote_plus }}/{{ table.name
|
|
13
|
+
<h2><a href="/-/edit-schema/{{ database.name|quote_plus }}/{{ tilde_encode(table.name) }}">{{ table.name }}</a></h2>
|
|
14
14
|
<p>{% for column in table.columns %}{{ column.name }}{% if not loop.last %}, {% endif %}{% endfor %}</p>
|
|
15
15
|
{% endfor %}
|
|
16
16
|
|
|
@@ -86,12 +86,12 @@ html body label {
|
|
|
86
86
|
{% endblock %}
|
|
87
87
|
|
|
88
88
|
{% block content %}
|
|
89
|
-
<h1>Edit table <a href="{{ base_url }}{{ database.name|quote_plus }}/{{ table
|
|
89
|
+
<h1>Edit table <a href="{{ base_url }}{{ database.name|quote_plus }}/{{ tilde_encode(table) }}">{{ database.name }}/{{ table }}</a></h1>
|
|
90
90
|
|
|
91
91
|
{% if can_rename_table %}
|
|
92
92
|
<h2>Rename table</h2>
|
|
93
93
|
|
|
94
|
-
<form action="{{ base_url }}-/edit-schema/{{ database.name|quote_plus }}/{{ table
|
|
94
|
+
<form action="{{ base_url }}-/edit-schema/{{ database.name|quote_plus }}/{{ tilde_encode(table) }}" method="post">
|
|
95
95
|
<input type="hidden" name="csrftoken" value="{{ csrftoken() }}">
|
|
96
96
|
<p><label>New name <input type="text" name="name"></label>
|
|
97
97
|
<input type="hidden" name="rename_table" value="1">
|
|
@@ -99,7 +99,7 @@ html body label {
|
|
|
99
99
|
</form>
|
|
100
100
|
{% endif %}
|
|
101
101
|
|
|
102
|
-
<form action="{{ base_url }}-/edit-schema/{{ database.name|quote_plus }}/{{ table
|
|
102
|
+
<form action="{{ base_url }}-/edit-schema/{{ database.name|quote_plus }}/{{ tilde_encode(table) }}" method="post">
|
|
103
103
|
<h2>Change existing columns</h2>
|
|
104
104
|
<ul class="sortable-columns">
|
|
105
105
|
{% for column in columns %}
|
|
@@ -134,7 +134,7 @@ html body label {
|
|
|
134
134
|
|
|
135
135
|
<h2>Add a column</h2>
|
|
136
136
|
|
|
137
|
-
<form action="{{ base_url }}-/edit-schema/{{ database.name|quote_plus }}/{{ table
|
|
137
|
+
<form action="{{ base_url }}-/edit-schema/{{ database.name|quote_plus }}/{{ tilde_encode(table) }}" method="post">
|
|
138
138
|
<input type="hidden" name="csrftoken" value="{{ csrftoken() }}">
|
|
139
139
|
<input type="hidden" name="add_column" value="1">
|
|
140
140
|
<p><label>Name <input type="text" name="name"></label>
|
|
@@ -156,7 +156,7 @@ table.foreign-key-options td {
|
|
|
156
156
|
}
|
|
157
157
|
</style>
|
|
158
158
|
|
|
159
|
-
<form action="{{ base_url }}-/edit-schema/{{ database.name|quote_plus }}/{{ table
|
|
159
|
+
<form action="{{ base_url }}-/edit-schema/{{ database.name|quote_plus }}/{{ tilde_encode(table) }}" method="post">
|
|
160
160
|
<input type="hidden" name="csrftoken" value="{{ csrftoken() }}">
|
|
161
161
|
<input type="hidden" name="action" value="update_foreign_keys">
|
|
162
162
|
<table class="foreign-key-options">
|
|
@@ -180,7 +180,7 @@ table.foreign-key-options td {
|
|
|
180
180
|
|
|
181
181
|
<p>The primary key column uniquely identifies each row in the table.</p>
|
|
182
182
|
|
|
183
|
-
<form action="{{ base_url }}-/edit-schema/{{ database.name|quote_plus }}/{{ table
|
|
183
|
+
<form action="{{ base_url }}-/edit-schema/{{ database.name|quote_plus }}/{{ tilde_encode(table) }}" method="post">
|
|
184
184
|
<input type="hidden" name="csrftoken" value="{{ csrftoken() }}">
|
|
185
185
|
<input type="hidden" name="action" value="update_primary_key">
|
|
186
186
|
<label for="primary_key">Primary key column </label>
|
|
@@ -201,7 +201,7 @@ table.foreign-key-options td {
|
|
|
201
201
|
|
|
202
202
|
<p>Indexes can speed up filter and sort operations against indexed columns.</p>
|
|
203
203
|
|
|
204
|
-
<form action="{{ base_url }}-/edit-schema/{{ database.name|quote_plus }}/{{ table
|
|
204
|
+
<form action="{{ base_url }}-/edit-schema/{{ database.name|quote_plus }}/{{ tilde_encode(table) }}" method="post">
|
|
205
205
|
<input type="hidden" name="csrftoken" value="{{ csrftoken() }}">
|
|
206
206
|
{% if non_primary_key_columns %}
|
|
207
207
|
<p><label for="id_add_index_column">
|
|
@@ -233,7 +233,7 @@ table.foreign-key-options td {
|
|
|
233
233
|
{% if can_drop_table %}
|
|
234
234
|
<h2>Drop table</h2>
|
|
235
235
|
|
|
236
|
-
<form id="drop-table-form" action="{{ base_url }}-/edit-schema/{{ database.name|quote_plus }}/{{ table
|
|
236
|
+
<form id="drop-table-form" action="{{ base_url }}-/edit-schema/{{ database.name|quote_plus }}/{{ tilde_encode(table) }}" method="post">
|
|
237
237
|
<input type="hidden" name="csrftoken" value="{{ csrftoken() }}">
|
|
238
238
|
<input type="hidden" name="drop_table" value="1">
|
|
239
239
|
<input type="submit" class="button-red" value="Drop this table">
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: datasette-edit-schema
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.8a2
|
|
4
4
|
Summary: Datasette plugin for modifying table schemas
|
|
5
5
|
Author: Simon Willison
|
|
6
6
|
License: Apache-2.0
|
|
@@ -13,7 +13,7 @@ Classifier: License :: OSI Approved :: Apache Software License
|
|
|
13
13
|
Requires-Python: >=3.8
|
|
14
14
|
Description-Content-Type: text/markdown
|
|
15
15
|
License-File: LICENSE
|
|
16
|
-
Requires-Dist: datasette >=1.
|
|
16
|
+
Requires-Dist: datasette >=1.0a13
|
|
17
17
|
Requires-Dist: sqlite-utils >=3.35
|
|
18
18
|
Provides-Extra: test
|
|
19
19
|
Requires-Dist: pytest ; extra == 'test'
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
datasette_edit_schema/__init__.py,sha256=
|
|
1
|
+
datasette_edit_schema/__init__.py,sha256=ImGK6H3TZQLDg3awi8csyN9qaT5zTu6enNOuEogQSgc,30998
|
|
2
2
|
datasette_edit_schema/utils.py,sha256=PURr7eOLOcZ7MQTCkZ_fDyeB39-MDhwIbBA-YeXSods,4388
|
|
3
3
|
datasette_edit_schema/static/draggable.1.0.0-beta.11.bundle.js,sha256=rpTEfd8N7sSY5n_mi6mwGz2f-dRXOgknFBuUXmwFnpY,202242
|
|
4
4
|
datasette_edit_schema/static/draggable.1.0.0-beta.11.bundle.min.js,sha256=JlHRb54CUGfor6ENxVjMq9rd_QRrRLoVJf-j3V_c52U,119723
|
|
5
5
|
datasette_edit_schema/templates/edit_schema_create_table.html,sha256=cUiS_LucrtvwpD_Nfb6ER4uZyhzTtPMzl3vkqhx9iGQ,3777
|
|
6
|
-
datasette_edit_schema/templates/edit_schema_database.html,sha256=
|
|
6
|
+
datasette_edit_schema/templates/edit_schema_database.html,sha256=gPPBVgTzdAWg4JgwrTfwHWdGBb89cObeqWneng4wQTk,543
|
|
7
7
|
datasette_edit_schema/templates/edit_schema_index.html,sha256=eNSOFFwv1gsOYP3fNQqcPh0gU5Ny5sDnngVZT5XiUNA,474
|
|
8
|
-
datasette_edit_schema/templates/edit_schema_table.html,sha256=
|
|
9
|
-
datasette_edit_schema-0.
|
|
10
|
-
datasette_edit_schema-0.
|
|
11
|
-
datasette_edit_schema-0.
|
|
12
|
-
datasette_edit_schema-0.
|
|
13
|
-
datasette_edit_schema-0.
|
|
14
|
-
datasette_edit_schema-0.
|
|
8
|
+
datasette_edit_schema/templates/edit_schema_table.html,sha256=8Sd8GjtTYhNXCQAWQuLdCg_awUZmCJD82qyM0RXkkK4,9406
|
|
9
|
+
datasette_edit_schema-0.8a2.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
10
|
+
datasette_edit_schema-0.8a2.dist-info/METADATA,sha256=nukoMkEvm9sf1Pt60nLvKVi4m64VWZLkE1Un_F4qUc0,5150
|
|
11
|
+
datasette_edit_schema-0.8a2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
12
|
+
datasette_edit_schema-0.8a2.dist-info/entry_points.txt,sha256=1-FeujFVTui7tFNBdz3hN5x4vRoanaAydYF5ljYsvp8,48
|
|
13
|
+
datasette_edit_schema-0.8a2.dist-info/top_level.txt,sha256=Cbx3sgneHtcDDxV5SVL8IyU8JvsSdXgpmZqw4oDuOzM,22
|
|
14
|
+
datasette_edit_schema-0.8a2.dist-info/RECORD,,
|
|
File without changes
|
{datasette_edit_schema-0.8a0.dist-info → datasette_edit_schema-0.8a2.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{datasette_edit_schema-0.8a0.dist-info → datasette_edit_schema-0.8a2.dist-info}/top_level.txt
RENAMED
|
File without changes
|