sqlite_orm icon indicating copy to clipboard operation
sqlite_orm copied to clipboard

Reading a db created by a different ORM

Open crabiner opened this issue 3 years ago • 2 comments
trafficstars

I have a db created by a different ORM (pony ORM in python) and I created a similar db in sqlite_orm When I try to load the pony ORM created db using sqlite_orm make_storage, it just overwrites the file with an empty db. I am able to do the other direction of reading db created by sqlite_orm in pony orm.

is this supposed to work? what are the requirements of a db file to be read by sqlite_orm

I can open both dbs in DB Browser for SQLite and below are the create table commands in both dbs: Sqlite_orm CREATE TABLE 'Keyframe' ( 'id' INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL , 'class_label' TEXT NOT NULL , 'state_char' TEXT NOT NULL , 'state_ind' INTEGER NOT NULL , 'creation_time_sec' INTEGER NOT NULL , 'creation_time_nanosec' INTEGER NOT NULL , 'optimization_time_sec' INTEGER NOT NULL , 'optimization_time_nanosec' INTEGER NOT NULL , 'covariance' TEXT NOT NULL , 'rotation' TEXT NOT NULL , 'pos_x_mm' INTEGER NOT NULL , 'pos_y_mm' INTEGER NOT NULL , 'pos_z_mm' INTEGER NOT NULL , UNIQUE(state_char, state_ind)) CREATE INDEX 'idx_keyframe__pos_x_mm_pos_y_mm_pos_z_mm' ON 'Keyframe' ("pos_x_mm", "pos_y_mm", "pos_z_mm") pony orm

CREATE TABLE "Keyframe" ( "id" INTEGER PRIMARY KEY AUTOINCREMENT, "class_label" TEXT NOT NULL, "state_char" TEXT NOT NULL, "state_ind" INTEGER NOT NULL, "creation_time_sec" INTEGER NOT NULL, "creation_time_nanosec" INTEGER NOT NULL, "optimization_time_sec" INTEGER NOT NULL, "optimization_time_nanosec" INTEGER NOT NULL, "covariance" REAL[] NOT NULL, "rotation" REAL[] NOT NULL, "pos_x_mm" INTEGER NOT NULL, "pos_y_mm" INTEGER NOT NULL, "pos_z_mm" INTEGER NOT NULL, CONSTRAINT "unq_keyframe__state_char_state_ind" UNIQUE ("state_char", "state_ind") ) CREATE INDEX "idx_keyframe__pos_x_mm_pos_y_mm_pos_z_mm" ON "Keyframe" ("pos_x_mm", "pos_y_mm", "pos_z_mm")

crabiner avatar Jun 30 '22 11:06 crabiner

I'm having the same problem. The file size doesn't change but the data is gone. The file is created by a python script and opens fine in DB Browser.

I will have to revert to use the sqlite3 c library as I am in a time crunch. But would love to know the resolution.

piperoc avatar Jul 29 '22 15:07 piperoc

@piperoc looks like your data is gone after sync_schema call. Data drop can happen if schema differs and cannot be altered with data saving. Check the different between schema in make_storage call and your database schema. Also you can call sync_schema_simulate before calling sync_schema and check return result to know what happens after real sync_schema call. Also our team has a different sqlite_orm version which has migrations API but it's license costs 1000$ per year

fnc12 avatar Jul 29 '22 17:07 fnc12

@crabiner @piperoc how are you doing? the issue is still open. Did you try to call sync_schema_simulate and check what it returns?

fnc12 avatar Oct 08 '23 13:10 fnc12

closing due to inactivity. Feel free to reopen if you have something not solved

fnc12 avatar Oct 13 '23 12:10 fnc12