Create Schema
-
The Connection object provides method
createSchema
to create meta-data schema, the valid meta-data type of schema (either node or edge) is acquired viaULTIPA.DBType
-
Create a node schema 'test' in current graphset
from ultipa import Connection, ULTIPA_REQUEST, ULTIPA conn = Connection(host='host:port', username="root", password="root") ret = conn.createSchema(ULTIPA_REQUEST.CreateSchema(name="test", type=ULTIPA.DBType.DBNODE, description="test")) print(ret.toJSON())
-
Create an edge schema 'test' in current graphset
from ultipa import Connection, ULTIPA_REQUEST, ULTIPA conn = Connection(host='host:port', username="root", password="root") ret = conn.createSchema(ULTIPA_REQUEST.CreateSchema(name="test", type=ULTIPA.DBType.DBEDGE, description="test")) print(ret.toJSON())
-
Create schema by composing uQL
from ultipa import Connection, ULTIPA_REQUEST, ULTIPA conn = Connection(host='host:port', username="root", password="root") ret = conn.uql("create().node_schema('<name>', '<desc?>')") ret = conn.uql("create().node_schema('<name>', '<desc?>')") print(ret.toJSON())
Show Schema
-
The Connection object provides method
showSchema
to show schemas in the current graphset, the valid meta-data type of schema (either node or edge) is acquired viaULTIPA.DBType
-
Show all node schemas in current graphset
from ultipa import Connection, ULTIPA_REQUEST, ULTIPA conn = Connection(host='host:port', username="root", password="root") ret = conn.showSchema(ULTIPA_REQUEST.ShowSchema(type=ULTIPA.DBType.DBNODE)) print(ret.toJSON())
-
Show all edge schemas in current graphset
from ultipa import Connection, ULTIPA_REQUEST, ULTIPA conn = Connection(host='host:port', username="root", password="root") ret = conn.showSchema(ULTIPA_REQUEST.ShowSchema(type=ULTIPA.DBType.DBEDGE)) print(ret.toJSON())
-
Show a certain node schema in current graphset
from ultipa import Connection, ULTIPA_REQUEST, ULTIPA conn = Connection(host='host:port', username="root", password="root") ret = conn.showSchema(ULTIPA_REQUEST.ShowSchema(type=ULTIPA.DBType.DBNODE, schema='test')) print(ret.toJSON())
-
Show a certain edge schema in current graphset
from ultipa import Connection, ULTIPA_REQUEST, ULTIPA conn = Connection(host='host:port', username="root", password="root") ret = conn.showSchema(ULTIPA_REQUEST.ShowSchema(type=ULTIPA.DBType.DBEDGE, schema='test')) print(ret.toJSON())
-
Show all schemas (both node and edge) in current graphset
from ultipa import Connection, ULTIPA_REQUEST, ULTIPA conn = Connection(host='host:port', username="root", password="root") ret = conn.showSchema() print(ret.toJSON())
-
Show schema by composing uQL
from ultipa import Connection, ULTIPA_REQUEST, ULTIPA conn = Connection(host='host:port', username="root", password="root") ret = conn.uql("show().node_schema()") ret = conn.uql("show().node_schema(@test)") ret = conn.uql("show().edge_schema()") ret = conn.uql("show().edge_schema(@test)") ret = conn.uql("show().schema()") print(ret.toJSON())
Alter Schema
-
Modify the name and/or description of a certain node schema in current graphset
from ultipa import Connection, ULTIPA_REQUEST, ULTIPA conn = Connection(host='host:port', username="root", password="root") ret = conn.alterSchema(ULTIPA_REQUEST.AlterSchema(schema='test', type=ULTIPA.DBType.DBNODE, new_description="test", new_name='test1')) print(ret.toJSON())
-
Modify the name and/or description of a certain edge schema in current graphset
from ultipa import Connection, ULTIPA_REQUEST, ULTIPA conn = Connection(host='host:port', username="root", password="root") ret = conn.alterSchema(ULTIPA_REQUEST.AlterSchema(schema='test', type=ULTIPA.DBType.DBEDGE, new_description="test", new_name='test1')) print(ret.toJSON())
-
Modify schema by composing uQL
from ultipa import Connection, ULTIPA_REQUEST, ULTIPA conn = Connection(host='host:port', username="root", password="root") ret = conn.uql("alter().node_schema(@<schema>).set({name: '<new_name?>', description: '<new_desc?>'})") ret = conn.uql("alter().edge_schema(@<schema>).set({name: '<new_name?>', description: '<new_desc?>'})") print(ret.toJSON())
Drop Schema
-
Delete a certain node schema (other than 'default') from current graphset
from ultipa import Connection, ULTIPA_REQUEST, ULTIPA conn = Connection(host='host:port', username="root", password="root") ret = conn.dropSchema(ULTIPA_REQUEST.DropSchema(schema='test', type=ULTIPA.DBType.DBNODE)) print(ret.toJSON())
-
Delete a certain edge schema (other than 'default') from current graphset
from ultipa import Connection, ULTIPA_REQUEST, ULTIPA conn = Connection(host='host:port', username="root", password="root") ret = conn.dropSchema(ULTIPA_REQUEST.DropSchema(schema='test', type=ULTIPA.DBType.DBEDGE)) print(ret.toJSON())
-
Delete schema by composing uQL
from ultipa import Connection, ULTIPA_REQUEST, ULTIPA conn = Connection(host='host:port', username="root", password="root") ret = conn.uql("drop().node_schema(@<schema>)") ret = conn.uql("drop().edge_schema(@<schema>)") print(ret.toJSON())