{ "info": { "author": "Andre Kuehne", "author_email": "andre.kuehne.77@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3" ], "description": "## sqlport - aspires to port Informix SQL to PostgreSQL\n\n```\n$ echo 'select first 1 hello from world' | sqlport\nSELECT hello FROM world LIMIT 1;\n```\n\n```\n$ sqlport -h\nusage: sqlport [-h] [--outfile OUTFILE | --outdir OUTDIR | --replace]\n [--file-list [FILE]] [--quiet] [--verbose] [--debug]\n [--parse-tree] [--lex] [--informix]\n [INFILE [INFILE ...]]\n\nPorts SQL code to another dialect.\n\npositional arguments:\n INFILE\n\noptional arguments:\n -h, --help show this help message and exit\n --outfile OUTFILE, -o OUTFILE\n\t\t\toutput file path pattern with place holders: \"#\" =\n\t\t\tinput file path; \"%\" = input file path with last file\n\t\t\textension removed; \"%%\" = input file path with last\n\t\t\ttwo file extensions removed; ...\n --outdir OUTDIR, -d OUTDIR\n output base directory\n --replace, -r replace input file\n --file-list [FILE], -f [FILE]\n\t\t\tread file list from file or stdin\n --quiet, -q do not output anything\n --verbose, -v verbose output\n --debug, -D debugging output\n --parse-tree, -T show parse tree\n --lex, -L show lexer output\n --informix, -i generate informix SQL\n```\n\n### Implemented transformations\n\n#### Data types\n\n| Informix | Postgres |\n| --------- | ------------------- |\n| `lvarchar` | `varchar` |\n| `varchar(x,y)` | `varchar(x)` |\n| `byte` | `bytea` |\n| `interval (1) year to month` | `interval` |\n\n#### Literals\n\n| Informix | Postgres |\n| --------- | ------------------- |\n| `current` | `current_timestamp` |\n| `today` | `current_date` |\n| `\"some text\"` | `'some text'` |\n\n#### Misc\n\n| Informix | Postgres |\n| --------- | ------------------- |\n| `SELECT FIRST 1 ...` | `SELECT ... LIMIT 1` |\n| `SELECT UNIQUE ...` | `SELECT DISTINCT ...` |\n| `SELECT ... INTO TEMP x` | `CREATE TEMP TABLE x AS SELECT ...` |\n| `SELECT x, y, z FROM TABLE(some_function(a, b)) AS t (x, y, z)` | SELECT x, y, z FROM some_function(a, b) AS t (x, y, z) |\n| `nvl(x, y)` | `coalesce(x, y)` |\n| `ALTER TABLE ADD CONSTRAINT PRIMARY KEY ...` | `ALTER TABLE ADD PRIMARY KEY ...` |\n| `UPDATE STATISTICS [FOR table_name]` | `ANALYZE [table_name]` |\n\n#### Procedures\n\n| Informix | Postgres |\n| -------- | -------- |\n| `CREATE PROCEDURE` | `CREATE FUNCTION` |\n| `DROP PROCEDURE` | `DROP FUNCTION` |\n| `RETURNING` | `RETURNS` |\n| no return value | `RETURNS void` |\n| `DEFINE x integer` | `x integer` in `DECLARE` block |\n| `DEFINE x, y integer` | converted to individual declarations |\n| `LET x = y` | `x := y` |\n| `IF ... ELIF ... END IF` | `IF ... ELSIF ... END IF` |\n| `WHILE x=y ... END WHILE` | `WHILE x=y LOOP ... END LOOP` |\n| `EXIT WHILE`, `EXIT FOR`, ... | `EXIT` |\n| `RAISE EXCEPTION -746, 0, \"some text\"` | `RAISE EXCEPTION \"Error: %\", 'some text'` |\n| semicolon optional after `END IF`, `END FOR`, ... | semicolon always required |\n| `EXECUTE PROCEDURE name(x,y)`, `CALL name(x, y)` | `SELECT name(x, y)`, `PERFORM name(x, y)` |\n\n#### MERGE\n\n- Informix:\n ```\n MERGE INTO x USING y ON y.y1 = x.x1\n WHEN MATCHED THEN UPDATE SET x.x2 = y.y2\n WHEN NOT MATCHED THEN INSERT (x1, x2) VALUES (y1, y2)\n ```\n- Postgres:\n ```\n INSERT INTO x (x1, x2)\n SELECT y1, y2 FROM y\n ON CONFLICT (x1) DO UPDATE SET x1 = y1, x2 = y2\n ```\n- `MERGE` without WHEN NOT MATCHES THEN INSERT is translated into UPDATE FROM syntax.\n\n#### Keywords as names\n\n- Informix: `all`, `end`, `default`, ...\n- Postgres: not allowed\n- append underscore, e.g. `all_`, `end_`, `default_`, ...\n\n#### Constraint names\n\n- Postgres: contraint name must differ from table name\n- Prefix constraint name, e.g. with `pk_`\n\n### Limited transformations\n\n#### SYSTEM\n\n- Informix: `SYSTEM \"sleep 10\"`\n- Postgres: `PERFORM system('sleep 10')`\n- The `system` function has to be defined separately\n\n#### ADD column BEFORE\n\n- Informix: `ALTER TABLE x ADD a int BEFORE c`\n- Postgres: `BEFORE` is not supported\n- `BEFORE c` is dropped\n\n#### FOREACH\n\n- Informix:\n ```\n FOREACH SELECT a, b INTO x, y FROM ...\n ...\n END FOREACH\n ```\n- Postgres:\n ```\n FOR record IN SELECT a AS x, b AS y\n FROM ... LOOP\n ...\n X := record x;\n y := record y;\n ...\n END LOOP;\n ```\n- Using the record type directly could be cleaner.\n\n#### OUTER(table)\n\n- Informix: `SELECT ... FROM a, OUTER(b)`\n- Postgres: not supported\n- Supports limited translation to ANSI JOINs for simple cases.\n\n#### Exception handlers and error codes\n\n- Informix:\n ```\n ON EXCEPTION IN (-206, -958)\n ...\n END EXCEPTION\n ```\n- Postgres:\n ```\n BEGIN\n ...\n EXCEPTION\n WHEN undefined_table OR duplicate_table THEN\n ...\n END\n ```\n- Only a few error codes are mapped\n- WITH RESUME is not supported\n- ON EXCEPTION without error code is not supported\n\n#### Unscaled decimal\n\n- Informix: `decimal(20)`\n- If you omit the scale in Informix it is not fixed.\n- If you omit the scale in Postgres it defaults to zero.\n- Currently these cases are translated to `DECIMAL(30,10)`.\n\n#### MATCHES\n\n- Informix: `MATCHES \"*[a-z]?\"`\n- Postgres: `SIMILAR TO \"%[a-z]_\"`\n- This is converted for literal string patterns, but not if the pattern is a variable.\n\n#### Slice\n\n- Informix: `text[2,4]`\n- Postgres: `substring(text from 2 for 3)`\n- This is automatically converted. However this does not work if the slice is on the left side of a `let` statement (variable assignment).\n\n### Not Supported\n\n| Informix | Postgres |\n| -------- | -------- |\n| `multiset(integer)` | |\n| `SET LOCK MODE` | |\n| `DEFINE GLOBAL` | |\n| `database[@server]:name` | |\n| `sys*` tables | |\n| `LET x, y = y, x` | |\n| `GRANT`, `REVOKE` | |\n| multiple return values | use `record` type or `OUT` paramters |\n| named return parameters | |\n\nIf something is not automatically translated a `NOT_SUPPORTED` message is included in the output.\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/ak-1/sqlport", "keywords": "", "license": "BSD", "maintainer": "Andre Kuehne", "maintainer_email": "andre.kuehne.77@gmail.com", "name": "sqlport", "package_url": "https://pypi.org/project/sqlport/", "platform": "", "project_url": "https://pypi.org/project/sqlport/", "project_urls": { "Homepage": "https://github.com/ak-1/sqlport" }, "release_url": "https://pypi.org/project/sqlport/0.2/", "requires_dist": [ "sly", "termcolor" ], "requires_python": "", "summary": "Aspires to port Informix SQL to PostgreSQL", "version": "0.2" }, "last_serial": 5122041, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "84966a764cf3b1c9b86d073d59933bcd", "sha256": "5403f41642cafdbff7e251083511f37d2651cd3ac7888782112cf338f5ac9019" }, "downloads": -1, "filename": "sqlport-0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "84966a764cf3b1c9b86d073d59933bcd", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 26336, "upload_time": "2019-03-30T11:25:45", "url": "https://files.pythonhosted.org/packages/f4/06/54d2099914d4153fe7a10022d830ab4727e6d43d0aae9abaaaf758ea22fe/sqlport-0.1-py3-none-any.whl" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "e647ccf022b838beec07bf3cbe9d91e7", "sha256": "05e08d8d6f96eb300dc3569368e0d51f41bc7d65ddd04f73986cf9c2261bad4f" }, "downloads": -1, "filename": "sqlport-0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "e647ccf022b838beec07bf3cbe9d91e7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 37831, "upload_time": "2019-04-10T04:07:07", "url": "https://files.pythonhosted.org/packages/be/df/2ea7d5e56971200a82a12b9a892fe8be7390fe86576e89918eea9e1a07da/sqlport-0.2-py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e647ccf022b838beec07bf3cbe9d91e7", "sha256": "05e08d8d6f96eb300dc3569368e0d51f41bc7d65ddd04f73986cf9c2261bad4f" }, "downloads": -1, "filename": "sqlport-0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "e647ccf022b838beec07bf3cbe9d91e7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 37831, "upload_time": "2019-04-10T04:07:07", "url": "https://files.pythonhosted.org/packages/be/df/2ea7d5e56971200a82a12b9a892fe8be7390fe86576e89918eea9e1a07da/sqlport-0.2-py3-none-any.whl" } ] }