Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to create edge using create edge statement #143

Closed
SaqlainHussainShah opened this issue Sep 21, 2021 · 2 comments
Closed

Unable to create edge using create edge statement #143

SaqlainHussainShah opened this issue Sep 21, 2021 · 2 comments

Comments

@SaqlainHussainShah
Copy link

Here is my code `from nebula2.gclient.net import ConnectionPool
from nebula2.Config import Config

define a config

config = Config()
config.max_connection_pool_size = 10

init connection pool

connection_pool = ConnectionPool()

ok = connection_pool.init([('localhost', 9669)], config)

session = connection_pool.get_session('root', 'nebula')

SHOW SPACES

session.execute("SHOW SPACES")

CREATE SPACE

SPACE_NAME = "nba"
CREATE_SPACE = "CREATE SPACE IF NOT EXISTS nba(partition_num = 5)" # replica_factor not working because single system
session.execute(CREATE_SPACE)

SELECT SPACE

SELECT_SPACE = "USE {}".format(SPACE_NAME)
session.execute(SELECT_SPACE)

DESCRIBE SPACE

session.execute("DESCRIBE SPACE nba")

SHOW TAGS, SPACES

result = session.execute('SHOW TAGS')
print(result)

#CREATE PLAYER TAG
PLAYER_SCHEMA = "name string NOT NULL, age int"
CREATE_PLAYER = "CREATE TAG player({})".format(PLAYER_SCHEMA)
session.execute(CREATE_PLAYER)

CREATE TEAM TAG

TEAM_SCHEMA = "name string"
CREATE_TEAM = "CREATE TAG team({})".format(TEAM_SCHEMA)
session.execute(CREATE_TEAM)

DESCRIBE TAGS GIVES DETAILS OF TAG

result = session.execute('DESCRIBE TAG player')
print(result)

CREATE TAG WITHOUT A PROPERTY

session.execute('CREATE TAG property_free()') # Without using () at the end was not creating this TAG

SHOW TAGS

session.execute("SHOW TAGS")

#DELETE A TAG
DELETE_TAG = "DROP SPACE nba"
session.execute(DELETE_TAG)

CREATE EDGE TYPE

CREATE_EDGE = "CREATE EDGE follow(degree int)"
session.execute(CREATE_EDGE)

session.execute("SHOW EDGES")

CREATE_EDGE = "CREATE EDGE serve(start_year int, end_year int)"
session.execute(CREATE_EDGE)
session.execute("SHOW EDGES")

session.execute("DESCRIBE EDGE serve")`

The output for session.execute("SHOW EDGES") and session.execute("DESCRIBE EDGE serve") is ResultSet(None)

@SaqlainHussainShah
Copy link
Author

The reason for not creating edges is that In my code I am deleting the space before creating edges. that was my mistake

@wey-gu
Copy link
Contributor

wey-gu commented Sep 22, 2021

Dear @SaqlainHussainShah,
Welcome to the Nebula Community! Glad to see it's solved.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants