-
-
Notifications
You must be signed in to change notification settings - Fork 28
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
Correctly duplicate empty tables #28
Comments
Can also confirm this. The dump seems to be incomplete when using django. In fact, it seems to completely omit some Django auth tables, like auth_groups. Otherwise it works flawlessly. Hope this gets fixed someday. Edit: This happened to me when I was trying to convert a full PostgreSQL database. I haven't checked if this happens with MySQL/Mariadb, though. |
Just found something which is kinda a baid-aid for this problem. If you're using django, you can do the following:
This will extract the schema of your empty sqlite database. I gave db-to-sqlite3 a quick read and it seems that there's no logic to handle empty tables. It could be a sqlalchemy bug too, but idk to be honest. |
Yeah this is definitely due to tables being empty.
|
The current code lazily avoids this by relying on |
db-to-sqlite/db_to_sqlite/cli.py Lines 101 to 106 in d24b35d
|
This SQLAlchemy method will give me details of the columns. Not sure how to make the types though: https://docs.sqlalchemy.org/en/13/core/reflection.html#sqlalchemy.engine.reflection.Inspector.get_columns |
I think I need to provide a mapping for this list of subclases (or a subset thereof - maybe just the base Text one maps to str for example): https://docs.sqlalchemy.org/en/13/core/type_basics.html#generic-types |
I can bring across |
For example:
|
Got this error:
It was because of |
Tried this on my blog and got the following SQLite schema for an empty table: CREATE TABLE [blog_comment] (
[id] INTEGER,
[object_id] INTEGER,
[body] TEXT,
[created] TEXT,
[name] TEXT,
[url] TEXT,
[email] TEXT,
[openid] TEXT,
[ip] TEXT,
[spam_status] TEXT,
[visible_on_site] INTEGER,
[spam_reason] TEXT,
[content_type_id] INTEGER,
FOREIGN KEY([content_type_id]) REFERENCES [django_content_type]([id])
);
CREATE INDEX [idx_blog_comment_content_type_id]
ON [blog_comment] ([content_type_id]); |
I'm just trying out this library with a blank django project. I've a project on heroku and I want to replicate the heroku database locally in sqlite, but it seems that db-to-sqlite is skipping some tables.
Command run -
Output -
When tried to run django locally, faced an error that django could not find
django_admin_log
, so I tried to see if tables have been copied correctly or not-The text was updated successfully, but these errors were encountered: