• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python models.db_connect函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中models.db_connect函数的典型用法代码示例。如果您正苦于以下问题:Python db_connect函数的具体用法?Python db_connect怎么用?Python db_connect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了db_connect函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: __init__

 def __init__(self):
     """
     Initializes database connection and sessionmaker.
     Creates website table.
     """
     engine = db_connect()
     self.Session = sessionmaker(bind=engine)
开发者ID:Gmulti,项目名称:Foot-Engine,代码行数:7,代码来源:pipelines.py


示例2: __init__

 def __init__(self):
     log.start(settings.LOG_FILE)
     try:
         engine = db_connect()
         self.Session = sessionmaker(bind=engine)
     except Exception as e:
         pass
开发者ID:zachhilbert,项目名称:freelist,代码行数:7,代码来源:pipelines.py


示例3: getallbehaviorsbygid

def getallbehaviorsbygid(query):
    engine = db_connect()
    Session = sessionmaker(bind=engine)
    session = Session()
    behaviors = []
    myquery = session.query(Behaviors).filter(Behaviors.tid==query['gid']).filter(Behaviors.uid>0).filter(Behaviors.bcode!=0).filter(Behaviors.bcode!=1).filter(Behaviors.bcode!=2).filter(Behaviors.bcode!=3).filter(Behaviors.bcode!=5).filter(Behaviors.bcode!=11).filter(Behaviors.bcode!=12).filter(Behaviors.tcode!=0).filter(Behaviors.tcode!=3).filter(Behaviors.tcode!=4)
    total = myquery.count()
    for instance in myquery.order_by(desc(Behaviors.t)).offset(query['offset']).limit(query['limit']):
        behavior = {}
        behavior['uid'] = instance.uid
        behavior['t'] = instance.t
        behavior['bcode'] = instance.bcode
        behavior['tcode'] = instance.tcode
        behavior['tid'] = instance.tid
        behaviors.append(behavior)
    #endfor
    session.close()
   
    hasMore = 1
    number = int(query['offset']) + int(query['limit'])
    if (number>=total):
        hasMore = 0
    
    print 'get behaviors by gid - ', query['offset'], query['limit'], number, total, hasMore    
 
    return { 'numFound':total, 'hasMore':hasMore, 'behaviors':behaviors}
开发者ID:fashionwu,项目名称:weixiao,代码行数:26,代码来源:behavior.py


示例4: createWeixiaoSimTask

    def createWeixiaoSimTask(self, potentialItem, items):
        print 'begin createWeixiaoSimTask...'
        # create json string 
        json_task = json.dumps({'item':potentialItem, 'existing':items}, separators=(',',':'))
        print json_task 

        # and put it to lelesimtask table of lelespider, FIXME
        #WeixiaoTaskService.addSimTask(json_task)
        engine = db_connect()
        Session = sessionmaker(bind=engine)
        session = Session()

        new_task = {}
        new_task['jsontask'] = json_task
        new_task['date'] = potentialItem['date']
        new_task['time'] = potentialItem['time']
        new_task['same'] = False
        new_task['status'] = '0'

        simtask = SimTask(**new_task)
        session.add(simtask)
        session.commit()
        session.close()

        print 'end createWeixiaoSimTask...'
开发者ID:fashionwu,项目名称:weixiao,代码行数:25,代码来源:main.py


示例5: __init__

 def __init__(self):
     """
     Initialize database connection and create tables.
     """
     engine = db_connect()
     create_tables(engine)
     self.Session = sessionmaker(bind=engine)
开发者ID:mcwitt,项目名称:apt-hunter,代码行数:7,代码来源:pipelines.py


示例6: importCalpendoIntoRMC

def importCalpendoIntoRMC(monthYear):
    result = run_query("call billingCalpendoByMonth('{monthYear}%')".format(monthYear=monthYear), "calpendo")
    s = db_connect("rmc")

    for row in result:
        row = list(row)
        for idx, val in enumerate(row):
            try:
                row[idx] = pymysql.escape_string(unicode(val))
            except UnicodeDecodeError:
                row[idx] = pymysql.escape_string(val.decode('iso-8859-1'))
        entry = Ris(accession_no=row[0], gco=row[1], project=row[2], MRN=row[3], PatientsName=row[4],
                    BirthDate=row[5], target_organ=row[6], target_abbr=row[7],
                    ScanDate=row[8], referring_md=row[9], Duration=row[10], ScanDTTM=row[11],
                    CompletedDTTM=row[12], Resource=row[13])
        s.add(entry)
        try:
            s.commit()
        except IntegrityError:
            print "Warning: Duplicate row detected in ris table."
            s.rollback()
        else:
            examEntry = Examcodes(target_abbr=row[7], target_organ=row[6])
            s.add(examEntry)
            try:
                s.commit()
            except IntegrityError:
                print "Warning: Examcode already exists."
                s.rollback()
    return result
开发者ID:ewong718,项目名称:tmiicentral,代码行数:30,代码来源:billing_sql.py


示例7: __init__

	def __init__(self):

		"""
		Initializes database connection and sessionmaker.
		Creates deals table.
		"""

		engine = db_connect()
		create_deals_table(engine)
		self.Session = sessionmaker( bind = engine )

		def process_item(self, item, spider):
			"""Save deals in the database.

			This method is called for every item pipeline component.

			"""
			session = self.Session()
			deal = Deals(**item)

			try:
				session.add(deal)
				session.commit()
			except:
				session.rollback()
				raise
			finally:
				session.close()

				return item
开发者ID:4bic-attic,项目名称:scrape,代码行数:30,代码来源:pipelines.py


示例8: __init__

	def __init__(self):
		"""Initialize database connecton and sessionmaker
		Create deals table"""

		engine = db_connect()
		create_deals_table(engine)
		self.Session = sessionmaker(bind=engine)
开发者ID:vaibhavmule,项目名称:learning-python,代码行数:7,代码来源:pipelines.py


示例9: main

def main():
    """Index alexa demographics
    """

    engine = db_connect()
    Session = sessionmaker(bind=engine)
    session = Session()

    settings = get_project_settings()
    settings.set('ITEM_PIPELINES',
                 {'demographic_scraper.demographic_scraper.pipelines.WebsiteDemographicPipeline': 300})
    settings.set('EXTENSIONS',
                 {'scrapy.telnet.TelnetConsole': None,})


    process = CrawlerProcess(settings)
    for website in session.query(WebsitesContent).all():
        demographic = list(session.query(Websites).filter_by(link=website.link))
        if len(demographic) is 0:
            url = website.link
            print website.link
            AlexaSpider.name = url
            process.crawl(AlexaSpider, url=url, db_session=session)
    process.start()
    process.stop()

    session.close()
开发者ID:piatra,项目名称:ssl-project,代码行数:27,代码来源:get_demographics.py


示例10: __init__

 def __init__(self, obj):
     threading.Thread.__init__(self)
     self.engine = db_connect()
     create_all_tables(self.engine)
     self.Session = sessionmaker(bind=self.engine)
     self.session = self.Session()
     self.obj = obj
开发者ID:fashionwu,项目名称:weixiao,代码行数:7,代码来源:behavior.py


示例11: __init__

    def __init__(self):
        ''' Initializes db connection and session maker.
            Creates deals table.
        '''

        engine = db_connect()
        create_deals_table(engine)
        self.Session = sessionmaker(bind=engine)
开发者ID:zelaznik,项目名称:scratchpad,代码行数:8,代码来源:pipelines.py


示例12: __init__

 def __init__(self):
     """
     initializes the database session
     creates search term tables
     """
     engine = db_connect()
     create_url_table(engine)
     self.Session = sessionmaker(bind=engine)
开发者ID:snoozan,项目名称:Article-Aggregator,代码行数:8,代码来源:pipelines.py


示例13: __init__

 def __init__(self):
     """
     Initializes database connection and sessionmaker.
     Creates tables.
     """
     self.engine = db_connect()
     create_tables(self.engine)
     self.Session = sessionmaker(bind=self.engine)
开发者ID:johnconnelly75,项目名称:newsCurator,代码行数:8,代码来源:pipelines.py


示例14: __init__

	def __init__(self):
		"""
		Initializez database connection and sessionmaker
		Create jobs table.
		"""
		engine = db_connect()
		create_jobs_table(engine)
		self.Session = sessionmaker(bind=engine)
开发者ID:kacak9229,项目名称:scrappy,代码行数:8,代码来源:pipelines.py


示例15: __init__

 def __init__(self):
     """
     Initializes database connection and sessionmaker.
     Creates nfl_te_games_2015 table if it doesn't exist.
     """
     engine = db_connect()
     create_tables(engine)
     self.Session = sessionmaker(bind=engine)
开发者ID:AncillaryStats,项目名称:AS-Scrapers,代码行数:8,代码来源:pipelines.py


示例16: __init__

 def __init__(self):
     '''
     initializes the database connections and sessionmaker
     creates all tables
     '''
     engine = db_connect()
     create_tables(engine)
     self.Session = sessionmaker(bind=engine)
开发者ID:mknudtsen,项目名称:event-data,代码行数:8,代码来源:pipelines.py


示例17: __init__

 def __init__(self):
     """
     Initializes database connection and sessionmaker.
     Creates deals table.
     """
     engine = db_connect()
     create_tc_tickets_table(engine)
     self.Session = sessionmaker(bind=engine)
开发者ID:loremIpsum1771,项目名称:Concert-Price-Tracker,代码行数:8,代码来源:pipelines.py


示例18: process_item

 def process_item(self, item, spider):
     if spider.name == 'updater':
         log.msg("Try saving item to database: %s." % item['codigo'])
         db = db_connect()
         table = db['pdl_proyecto']
         table.update(item, ['codigo'])
         return item
     return item
开发者ID:MrBaatezu,项目名称:proyectos_de_ley_scraper,代码行数:8,代码来源:pipelines.py


示例19: __init__

	def __init__(self):
		"""
		Initializes the class by defining engine, deals table and connecting to db with defined engine.
		Creates deals table.
		"""
		engine = db_connect()
		create_deals_table(engine)
		self.Session = sessionmaker(bind=engine)
开发者ID:yanniey,项目名称:Scrapy_livingsocial_chicago,代码行数:8,代码来源:pipelines.py


示例20: __init__

 def __init__(self):
   """
   Initialize database connection and sessionmaker
   Creates deals table
   """
   engine = db_connect()
   create_deals_table(engine)
   self.Session = sessionmaker(bind=engine) #binding/connection to db with the defined engine
开发者ID:joshuaNewman10,项目名称:new-coder,代码行数:8,代码来源:pipelines.py



注:本文中的models.db_connect函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.get_sorted_profiles函数代码示例发布时间:2022-05-27
下一篇:
Python models.create_tables函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap