Compare commits
3 Commits
dfc1e8bf8b
...
0f3cd9be19
Author | SHA1 | Date |
---|---|---|
|
0f3cd9be19 | |
|
a03a1e96d3 | |
|
6ebb397a86 |
|
@ -0,0 +1,22 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2020 Peter J. Holzer
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
|
12
README.md
12
README.md
|
@ -1,2 +1,14 @@
|
||||||
ProcruSQL
|
ProcruSQL
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
Make a database fit its description.
|
||||||
|
|
||||||
|
Why?
|
||||||
|
----
|
||||||
|
|
||||||
|
To be written ...
|
||||||
|
|
||||||
|
Syntax
|
||||||
|
------
|
||||||
|
|
||||||
|
To be written ...
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
[build-system]
|
||||||
|
requires = [
|
||||||
|
"setuptools>=42",
|
||||||
|
"wheel"
|
||||||
|
]
|
||||||
|
build-backend = "setuptools.build_meta"
|
|
@ -0,0 +1,28 @@
|
||||||
|
[metadata]
|
||||||
|
name = ProcruSQL
|
||||||
|
version = 0.0.1
|
||||||
|
author = Peter J. Holzer
|
||||||
|
author_email = hjp@hjp.at
|
||||||
|
description = Make a database fit its description
|
||||||
|
long_description = file: README.md
|
||||||
|
long_description_content_type = text/markdown
|
||||||
|
url = https://git.hjp.at:3000/hjp/procrusql
|
||||||
|
project_urls =
|
||||||
|
Bug Tracker = https://git.hjp.at:3000/hjp/procrusql/issues
|
||||||
|
classifiers =
|
||||||
|
Programming Language :: Python :: 3
|
||||||
|
License :: OSI Approved :: MIT License
|
||||||
|
Operating System :: OS Independent
|
||||||
|
|
||||||
|
[options]
|
||||||
|
package_dir =
|
||||||
|
= src
|
||||||
|
packages = find:
|
||||||
|
python_requires = >=3.8
|
||||||
|
|
||||||
|
[options.packages.find]
|
||||||
|
where = src
|
||||||
|
|
||||||
|
[options.entry_points]
|
||||||
|
console_scripts =
|
||||||
|
procrusql-fit = procrusql:main
|
|
@ -1,4 +1,5 @@
|
||||||
import logging
|
import logging
|
||||||
|
import sys
|
||||||
|
|
||||||
import psycopg2
|
import psycopg2
|
||||||
from psycopg2 import sql
|
from psycopg2 import sql
|
||||||
|
@ -241,3 +242,19 @@ def dump_dot():
|
||||||
for i in range(1, len(in_order)):
|
for i in range(1, len(in_order)):
|
||||||
print(f"\t{in_order[i-1]} -> {in_order[i]} [style=dashed]")
|
print(f"\t{in_order[i-1]} -> {in_order[i]} [style=dashed]")
|
||||||
print("}")
|
print("}")
|
||||||
|
|
||||||
|
def main():
|
||||||
|
logging.basicConfig(format="%(asctime)s %(levelname)s %(name)s %(lineno)d | %(message)s", level=logging.DEBUG)
|
||||||
|
with open(sys.argv[1]) as rf:
|
||||||
|
text = rf.read()
|
||||||
|
ps = procrusql.parser.ParseState(text)
|
||||||
|
|
||||||
|
ps2 = procrusql.parser.parse_ruleset(ps)
|
||||||
|
|
||||||
|
if not ps2:
|
||||||
|
ps.printerror()
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
db = psycopg2.connect(sys.argv[2])
|
||||||
|
procrusql.fit(db, ps2.ast)
|
||||||
|
|
|
@ -291,17 +291,3 @@ def rulename():
|
||||||
rulenum += 1
|
rulenum += 1
|
||||||
return f"__rule_{rulenum}"
|
return f"__rule_{rulenum}"
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
logging.basicConfig(format="%(asctime)s %(levelname)s %(name)s %(lineno)d | %(message)s", level=logging.DEBUG)
|
|
||||||
with open(sys.argv[1]) as rf:
|
|
||||||
text = rf.read()
|
|
||||||
ps = ParseState(text)
|
|
||||||
|
|
||||||
ps2 = parse_ruleset(ps)
|
|
||||||
|
|
||||||
if not ps2:
|
|
||||||
ps.printerror()
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
db = psycopg2.connect(sys.argv[2])
|
|
||||||
procrusql.fit(db, ps2.ast)
|
|
Loading…
Reference in New Issue