Re: [Modeling-users] SQLite schema generation with -c does not use semicolons
Status: Abandoned
Brought to you by:
sbigaret
From: Sebastien B. <sbi...@us...> - 2003-10-04 13:07:45
|
Hi, Ernesto Revilla <er...@si...> wrote: > Hi, >=20 > I've installed modeling 0.9-pre15, with sqlite (2.8.6) >=20 > when I create the schema with mdl_generate_DB_schema.py -c then I get out= put with no semicolons (;) separating the SQL commands, and this is not und= erstood by sqlite. >=20 > I modified line 99 of the script (mdl_generate_DB_schema.py) to include a= semicolon: > str+=3D'%s;\n'%sqlExpr.statement() >=20 > now I can do a: > mdl_generate_DB_schema.py -c -C mymodel.py >schema.sql > sqlite mymodel.sqlite < schema.py >=20 > Directly creating the schema (not specifying the -c option) worked correc= tly. Okay, your RFE #812708 has been addressed, see the patch attached to: https://sf.net/tracker/index.php?func=3Ddetail&aid=3D812708&group_id=3D5893= 5&atid=3D489338 (the patch was checked-in the cvs main trunk for mdl_generate_DB_schema.py rev1.8) Note that this has been added to the script itself, not to the core (in DatabaseAdaptors/): it seems a common habit to cursor.execute() SQL statements that do not end with ';', even though this is in the SQL standard. There's an another reason why I do not want that the framework appends semicolons to the sql statements: it gives the impression that statements can be concatenated and executed in a single call to cursor.execute(). But that's not the case, and worse: some python db-frontends simply ignores all but the last statement, while others actually return the result for each statements. This will be in the next release. Note that the old behaviour can still be obtained by supplying an empty string to the new option -e/--end-with. Last note, when things like these change from a version to another, I now always append a line in the file MIGRATION in the root directory. This is a good habit to keep an eye on this file before installing a new version. Cheers, -- S=E9bastien. |