-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathtest_updates.py
More file actions
27 lines (20 loc) · 904 Bytes
/
test_updates.py
File metadata and controls
27 lines (20 loc) · 904 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"""Small helper script to run the parser against a sample DDL."""
from simple_ddl_parser import DDLParser
def main() -> None:
ddl = """
CREATE TABLE pole.t_zuschauer (
id int4 GENERATED BY DEFAULT AS IDENTITY( INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START 1 CACHE 1 NO CYCLE) NOT NULL, -- Zuschauer-Nr.(Primärschlüssel)
email varchar(50) NULL, -- email-Adresse
CONSTRAINT t_zuschauer_email CHECK (((email IS NULL) OR ((email)::text = ''::text) OR ((email)::text ~* '([a-zA-Z0-9._%+-]+)@([a-zA-Z0-9.-]+)\.[a-zA-Z]{2,}'::text))),
CONSTRAINT t_zuschauer_id PRIMARY KEY (id)
);
"""
parser = DDLParser(ddl)
result = parser.run()
print(result)
if __name__ == "__main__":
main()
# Example proposal (not implemented yet) for a BigQuery schema helper:
# result = DDLParser(ddl).run()
# bq_schema = DDLParser(ddl).to_bigquery_schema(table="users")
# print(bq_schema)