hadoop
?1.Hive分區(qū)創(chuàng)建表
Hive>create? table t_user_p(id int, name string)
Partitioned by (country string)
Row format delimited fields terminated by ‘,’;
2.mongoDB數據庫集合,文檔,查詢
(1)查看集合
from pymongo import MongoClient
class Test:
?????? def _ _init _ _(self):
?????????? self.client=MongoClient(’192.168.121.134’,27017)
??? ??? def getColl(self):
???????????? articledb = self.client[”articledb”]
???????????? collections=articledb.list_collection_names()
???????????? for collection in collections:
??????????????????? print(collection)
if _ _name _ _ ==’_ _main_ _’:
????????? test = Test()
?????????? test.getColl()
(2)創(chuàng)建集合
from pymongo import MongoClient
class Test:
?????? def _ _init _ _(self):
?????????? self.client=MongoClient(’192.168.121.134’,27017)
?????? def createColl(self):
???????????? articledb = self.client[”articledb”]
???????????? articledb.create_collection(”itcast”)
? if _ _name _ _ ==’_ _main_ _’:
??????? test = Test()
??????? test.createColl()
(3)刪除集合
from pymongo import MongoClient
class Test:
?????? def _ _init _ _(self):
?????????? self.client=MongoClient(’192.168.121.134’,27017)
?????? def dropColl(self):
??????????? articledb = self.client[”articledb”]
???????????? articledb.drop_collection(”itcast”)
? if _ _name _ _ ==’_ _main_ _’:
??????? test = Test()
??????? test.dropColl()
(3)查看文檔
from pymongo import MongoClient
class Test:
?????? def _ _init _ _(self):
?????????? self.client=MongoClient(’192.168.121.134’,27017)
?????? def findDoc(self):
??????????? self.articledb = self.client[”articledb”]
??????????? comment = self.articledb[”comment”]
?????????? documents = comment.find()
????????????????????????? for ?document in documents:
?????????????????? print( document)
? if _ _name _ _ ==’_ _main_ _’:
??????? test = Test()
??????? test.findDocl()
?