`

a naive way to use dictcursor of psycopg2 with twisted adbapi

 
阅读更多

make a new file called fakedb.py

 

and copy some contents from psycopg1.py from psycopg2 package

 

 

class connection(_2connection):

    """psycopg 1.1.x connection."""

 

    def cursor(self):

        """cursor() -> new psycopg 1.1.x compatible cursor object"""

        return _2connection.cursor(self, cursor_factory=psycopg2.extras.DictCursor)

 

    def autocommit(self, on_off=1):

        """autocommit(on_off=1) -> switch autocommit on (1) or off (0)"""

        if on_off > 0:

            self.set_isolation_level(_ext.ISOLATION_LEVEL_AUTOCOMMIT)

        else:

            self.set_isolation_level(_ext.ISOLATION_LEVEL_READ_COMMITTED)

 

the point is to specify cursor_factory as DictCursor..

 

 

now use this file with adbapi like

 

 

adbapi.ConnectionPool("fakedb", database="test",host='localhost',\

                                  port=9000,user='mathgl')

 

 

 

分享到:
评论

相关推荐

    Learning.Data.Mining.with.Python.1784396052

    This book teaches you to design and develop data mining applications using a variety of datasets, starting with basic classification and affinity analysis. Next, we move on to more complex data types ...

    Learning.Predictive.Analytics.with.R.1782169350

    It offers you a useful way of interpreting the data that's specific to this book, but that can also be applied to any other data. Table of Contents Chapter 1: Setting GNU R for Predictive Analytics ...

    Data Science from Scratch : First Principles with Python

    Data science libraries, frameworks, modules, and toolkits are great for doing data science, but they’re also a good way to dive into the discipline without actually understanding data science....

    Mastering Machine Learning with scikit-learn [2017,第二版]

    By the end of this book, you will master all required concepts of scikit-learn to build efficient models at work to carry out advanced tasks with the practical approach. What you will learn Review ...

    Data Science from Scratch First Principles with Python

    Data science libraries, frameworks, modules, and toolkits are great for doing data science, but they’re also a good way to dive into the discipline without actually understanding data science....

    Affective Assessment by digital processing of the pupil diameter

    classification algorithms were used to evaluate the overall performance of the identification of “stress” states in the computer users, achieving an average accuracy of 83.16 percent, with the ...

    Data.Science.from.Scratch.First.Principles.with.Python

    Data science libraries, frameworks, modules, and toolkits are great for doing data science, but they’re also a good way to dive into the discipline without actually understanding data science....

    Machine Learning Made Easy with R

    YOUR PERSONAL BLUE PRINT: Through a simple to follow intuitive step by step process, you will learn how to use the most popular machine learning algorithms using R. Once you have mastered the process,...

    Data Science from Scratch- First Principles with Python(O'Reilly,2015)

    Data science libraries, frameworks, modules, and toolkits are great for doing data science, but they’re also a good way to dive into the discipline without actually understanding data science....

    Learning.Boost.Cplusplus.Libraries.1783551216

    This book teaches you to design and develop data mining applications using a variety of datasets, starting with basic classification and affinity analysis. Next, we move on to more complex data types ...

    Mastering Machine Learning with scikit-learn -2017.7.24

    By the end of this book, you will master all required concepts of scikit-learn to build efficient models at work to carry out advanced tasks with the practical approach. What you will learn Review ...

    R.Unleash.Machine.Learning.Techniques

    This Learning Path will take you through the fundamentals of R and demonstrate how to use the language to solve a diverse range of challenges through machine learning. Accessible yet comprehensive, it...

    NIST SP800-120.pdf

    In addition to these older and less secure methods, there are now a number of stronger EAP methods intended for integrated use with standard wireless access protocols, such that the keys generated in ...

    LuaUnicode icu-lua

    Happily UTF-8 is designed so that it is relatively easy to count the number of unicode symbols in a string: simply count the number of octets that are in the ranges 0x00 to 0x7f (inclusive) or 0xC2 to...

    Mastering Machine Learning with scikit-learn 第二版 2017

    Mastering Machine Learning with scikit-learn (2 ed) (True PDF + AWZ3 + codes) Table of Contents Preface 1 Chapter 1: The Fundamentals of Machine Learning 6 Defining machine learning 6 Learning from ...

    CMVision 论文

    A naive approach could require up to 192 comparisons for the same classification. The algorithms and representations are described, as well as descriptions of three applications in which it has been ...

    Unity 5.x Game AI Programming Cookbook

    Use techniques such as A*and A*mbush to empower your agents with path finding capabilities. Create a representation of the world and make agents navigate it Construct decision-making systems to make ...

    Thoughtful.Machine.Learning.with.Python.epub

    With this practical guide, author Matthew Kirk shows you how to integrate and test machine learning algorithms in your code, without the academic subtext. Featuring graphs and highlighted code ...

    LOGIC IN COMPUTER SCIENCE Modelling and Reasoning about Systems

    and a section on the use of the object modelling language Alloy and its analyserforsp ecifying and exploring under-specified first-orderlogic models with respect to properties written in first-order ...

    Data Science from Scratch

    Data science libraries, frameworks, modules, and toolkits are great for doing data science, but they’re also a good way to dive into the discipline without actually understanding data science....

Global site tag (gtag.js) - Google Analytics