From brett at python.org Tue Nov 14 15:14:43 2017 From: brett at python.org (Brett Cannon) Date: Tue, 14 Nov 2017 20:14:43 +0000 Subject: [Python-porting] Ask a question about Python accessing mongodb. Thanks. In-Reply-To: References: Message-ID: This list is about porting Python 2 code to Python 3, not general Python support. You can try asking on IRC or whomever is providing your Mongo library for help. On Sat, 11 Nov 2017 at 12:38 zhongxiaobin76 via Python-porting < python-porting at python.org> wrote: > When I found problems in the process of accessing mongodb with Python, > Who can I ask for help? > > > I want to create an object with Python to receive a document in mongodb, and the document format is like this: > > { "_id" : ObjectId("59f2d36fb934f31fdc002485"), "Name" : "???1711", "Date" : "20 > > 14/12/12", "data" : [ { "time" : "0901", "Open" : "13280.00", "Max" : "13280.00" > > , "Min" : "13280.00", "Close" : "13280.00", "Volume" : "0", "Amount" : "580", "S > > ettlement" : "0.00", "EXPMA1" : "13304.91", "EXPMA2" : "13301.51" }, { "time" : > > "0902", "Open" : "13280.00", "Max" : "13280.00", "Min" : "13280.00", "Close" : " > > 13280.00", "Volume" : "0", "Amount" : "580", "Settlement" : "0.00", "EXPMA1" : " > 13301.08", "EXPMA2" : "13300.66" }]} > There are about 300 records in the data. > > > How do I write an object that encapsulates the Mongo document like the object VtBarData in the code below? > > def loadBar(self, dbName, collectionName, days): > print "zxb ctaEngine CtaEngine loadBar days = ", days > startDate = self.today - timedelta(days) > > d = {'datetime':{'$gte':startDate}} > barData = self.mainEngine.dbQuery(dbName, collectionName, d, 'datetime') > > l = [] > for d in barData: > print "zxb ctaEngine CtaEngine loadBar d = ", d > bar = VtBarData() > bar.__dict__ = d > l.append(bar) > return l > > > _______________________________________________ > Python-porting mailing list > Python-porting at python.org > https://mail.python.org/mailman/listinfo/python-porting > -------------- next part -------------- An HTML attachment was scrubbed... URL: