-
-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Table renaming: db.rename_table() and sqlite-utils rename-table #565
Comments
For the CLI: sqlite-utils rename-table data.db old_table_name new_table_name For the Python code, should it go on Table or on Database? db["foo"].rename_table("bar")
db.rename_table("foo", "bar") I think I like the second better, it's slightly more clear. Also need a design for an option for the |
Trying out a simple first implementation: >>> from sqlite_utils import Database
>>> db = Database(memory=True, tracer=print)
PRAGMA recursive_triggers=on; None
>>> db["foo"].insert({"id": 1})
select name from sqlite_master where type = 'view' None
select name from sqlite_master where type = 'table' None
select name from sqlite_master where type = 'view' None
select name from sqlite_master where type = 'table' None
select name from sqlite_master where type = 'view' None
CREATE TABLE [foo] (
[id] INTEGER
);
None
select name from sqlite_master where type = 'view' None
INSERT INTO [foo] ([id]) VALUES (?); [1]
select name from sqlite_master where type = 'table' None
select name from sqlite_master where type = 'table' None
PRAGMA table_info([foo]) None
<Table foo (id)>
>>> db.rename_table("foo", "baz")
ALTER TABLE [foo] RENAME TO [baz] None
>>> print(db.schema)
select sql from sqlite_master where sql is not null None
CREATE TABLE "baz" (
[id] INTEGER
); |
I think |
Manually testing new
|
Originally posted by @simonw in simonw/llm#65 (comment)
The text was updated successfully, but these errors were encountered: