def _initialize_graph_connection(config): """Initialize a graph connection with the given configuration.""" graph = Graph(config, strict=True) base_node = declarative_node() base_relationship = declarative_relationship() graph.include( graph.build_mapping(base_node, base_relationship, auto_plural=True)) return graph
def _initialize_graph_connection(config, initial_drop=False): """Initialize a graph connection with the given configuration.""" local_config = deepcopy(config) local_config.initial_drop = initial_drop graph = Graph(local_config, strict=True) base_node = declarative_node() base_relationship = declarative_relationship() graph.include( graph.build_mapping(base_node, base_relationship, auto_plural=True)) return graph
def get_pyorient_client(): db_url = ''.join([ 'plocal://', server_config.ORIENTDB_HOST, ':2424', '/', server_config.ORIENTDB_DB ]) graph = Graph(Config.from_url(db_url, server_config.ORIENTDB_USER, server_config.ORIENTDB_PASSWORD), strict=True) graph.include( graph.build_mapping(declarative_node(), declarative_relationship(), auto_plural=False)) return graph
def db_setup(HOST: str, USER: str, dbname: str, PASSW: str, PORT: str, keep: bool): """sets up database :param HOST: OGM Graph ref :param USER: OGM Graph ref :param dbname: OGM Graph ref :param PASSW: OGM Graph ref :param PORT: OGM Graph ref :param keep: boolean value to keep or destroy database """ print('(connecting to db)') clear_database = '' if (not keep): clear_database = input( 'Are you sure you want to delete the database? (Y/N)') if clear_database in ['Y', 'y', 'Yes', 'yes', 'YES']: print('(dropping database)') g = Graph(Config.from_url(dbname, USER, PASSW, initial_drop=True)) g.create_all(Node.registry) g.create_all(Relationships.registry) else: print('(keeping database)') g = Graph(Config.from_url(dbname, USER, PASSW, initial_drop=False)) SchemaNode = declarative_node() SchemaRelationship = declarative_relationship() classes_from_schema = g.build_mapping(SchemaNode, SchemaRelationship, auto_plural=True) g.include(classes_from_schema) g.client.command( "ALTER DATABASE DATETIMEFORMAT \"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\"") print('our db g', g) return g