hadoop
1.Hive分区创建表
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)创建集合
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()