@@ -71,6 +71,44 @@ def read_data(csv):
71
71
72
72
return records
73
73
74
+ def query_documents (client ):
75
+ documents = client .get_all_documents ()
76
+
77
+ # documents comes back as a iterable that can be convert into a list
78
+ print ("\n All documents\n " )
79
+ print (list (documents ))
80
+
81
+ matches = client .query_document ({"@type" : "Netflix" ,
82
+ "type_of" : "Movie" ,
83
+ "release_year" : "2020" })
84
+
85
+ # matches comes back as a iterable that can be convert into a list
86
+ print ("\n Documents matches\n " )
87
+ print (list (matches ))
88
+
89
+ # If you want to get a specific number of records, just add count=number when calling both functions:
90
+ documents = client .get_all_documents (count = 5 )
91
+ matches = client .query_document ({"@type" : "Netflix" ,
92
+ "type_of" : "Movie" ,
93
+ "release_year" : "2020" }, count = 5 )
94
+
95
+ def branches (client ):
96
+ #You can create a new branch by calling the create_branch method
97
+ client .create_branch ("some_branch" , empty = False )
98
+
99
+ # When empty is set to False, a new branch will be created,
100
+ # containing the schema and data inserted into the database previously.
101
+ # If set to True, an empty branch will be created.
102
+ client .create_branch ("some_branch1" , empty = True )
103
+
104
+ # You can delete a branch by calling the delete and passing the name of the branch as parameter.
105
+ client .delete_branch ("some_branch" )
106
+
107
+ # List all branches
108
+ branches = client .get_all_branches ()
109
+
110
+ print (branches )
111
+
74
112
if __name__ == "__main__" :
75
113
db_id = "Netflix"
76
114
url = "netflix.csv"
@@ -89,3 +127,13 @@ def read_data(csv):
89
127
insert_data (client , url )
90
128
results = client .get_all_documents (count = 10 )
91
129
print ("\n RESULTS\n " , list (results ))
130
+
131
+ print ("\n QUERYING DOCUMENTS\n " )
132
+ query_documents (client )
133
+
134
+ print ("\n Branches\n " )
135
+ branches (client )
136
+
137
+ # Get the whole commit history:
138
+ commit_history = client .get_commit_history ()
139
+ print ("\n COMMIT HISTORY\n " ,commit_history )
0 commit comments