-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
utility db function for statement sql table
- Loading branch information
Showing
2 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
from nomenklatura.statement.statement import Statement, StatementDict | ||
from nomenklatura.statement.serialize import CSV, JSON, FORMATS | ||
from nomenklatura.statement.serialize import CSV, JSON, PACK, FORMATS | ||
from nomenklatura.statement.serialize import write_statements | ||
from nomenklatura.statement.serialize import read_statements, read_path_statements | ||
from nomenklatura.statement.db import make_statement_table | ||
|
||
__all__ = [ | ||
"Statement", | ||
"StatementDict", | ||
"CSV", | ||
"JSON", | ||
"PACK", | ||
"FORMATS", | ||
"write_statements", | ||
"read_statements", | ||
"make_statement_table", | ||
"read_path_statements", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from sqlalchemy import MetaData, Table, Column, DateTime, Unicode, Boolean | ||
|
||
KEY_LEN = 255 | ||
VALUE_LEN = 65535 | ||
|
||
|
||
def make_statement_table(metadata: MetaData, name: str = "statement") -> Table: | ||
return Table( | ||
name, | ||
metadata, | ||
Column("id", Unicode(KEY_LEN), primary_key=True, unique=True), | ||
Column("entity_id", Unicode(KEY_LEN), index=True, nullable=False), | ||
Column("canonical_id", Unicode(KEY_LEN), index=True, nullable=True), | ||
Column("prop", Unicode(KEY_LEN), nullable=False), | ||
Column("prop_type", Unicode(KEY_LEN), nullable=False), | ||
Column("schema", Unicode(KEY_LEN), nullable=False), | ||
Column("value", Unicode(VALUE_LEN), nullable=False), | ||
Column("original_value", Unicode(VALUE_LEN), nullable=True), | ||
Column("dataset", Unicode(KEY_LEN), index=True), | ||
Column("lang", Unicode(KEY_LEN), nullable=True), | ||
Column("target", Boolean, default=False, nullable=False), | ||
Column("external", Boolean, default=False, nullable=False), | ||
Column("first_seen", DateTime, nullable=False), | ||
Column("last_seen", DateTime, index=True), | ||
) |