Psycopg2 Threadedconnectionpool

The pg_simple module provides a simple yet efficient layer over psycopg2 providing Python API for common SQL functions, explicit and implicit transactions management and database connection pooling for single and multi-threaded applications. python psycopg2 连接pg 建立连接池 utf-8 -*-from psycopg2. pool Creating new PostgreSQL connections can be an expensive operation. 我正在开发Flask API,我有以下代码使用Psycopg2建立连接池. Retry decorator. getconn for p in pools] pdb = ParallelConnection (connections). 基本上,我设置了我的本地Postgres服务器,需要做成千上万的查询,所以我使用了Python psycopg2package. Ready to use for the connection pool. Since data across each company needs to be segregated, I used postgresql schemas to make it all work. When gunicorn forks new process they will copy these connections. Your connection doesn't fail if it's blocked waiting, and you still get your response faster than checking for open connections. Programming with Python and PostgreSQL 1. ThreadedConnectionPool(minconn, maxconn, *args, **kwargs) A connection pool that works with the threading module. class psycopg2. context_managers import ConnectionContextManager from postgres. They are extracted from open source Python projects. connect(conn_string) cursor = conn. 0 specification and the thread safety (several threads can share the same connection). OK, I Understand. just want to bump this answer up some more, was a perfect solution to the misleading 'ThreadedConnectionPool' – Sam Palmer Oct 11 at 16:08 which is why i like the queue solution. if _sa_class is not None and isinstance (statement, _sa_class):. Is this a problem with psycopg2's C libraries running in the Cloud Function's environment? How do I fix google-cloud-functions psycopg2. pool import ThreadedConnectionPool,SimpleConnectionPool,PersistentConnectionPool from constant. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. El 1 de mayo de 2012 15:46, Juan Antonio escribió:. Note This pool class can be safely used in multi-threaded applications. Hola a todos, Estoy todavía intentando instalar GNU health pero ahora en ubuntu lucid lynx y me gustaría preguntaros como habéis instalado tryton con todo lo necesario ya que me sigue dando errores de dependencias entre otros. UNICODEARRAY) except ImportError: # Python 3 import urllib. Databases are essential to most applications, however most database interaction is often overlooked by Python developers who use higher level libraries like Django or SQLAlchemy. Python psycopg2 模块, pool() 实例源码. Gzip compression shortcuts. GitHub Gist: star and fork kenvac's gists by creating an account on GitHub. To reduce the request size (currently 36954112 bytes), reduce PostgreSQL's shared memory usage, perhaps by reducing shared_buffers or max_connections. 32-38 linux-headers-2. Вполне можно использовать простейший штатный пул подключений от psycopg2. parse as urlparse import psycopg2 from psycopg2. Очевидно, что на нагруженных сервисах и речи быть не может об ужасно дорогих операциях соединения с базой на каждый чих. I would have a web hook on Git which triggers a Jenkins job based on the merge to a specific branch (such as whenever a developer merged to master). 模块列表; 函数列表. It has a thin Python module wrapper around it to load it and provide some of the interface functionality that's easier to write in pure Python. 我已经在这里查看了几个“太多客户”的相关主题,但仍然无法解决我的问题,所以我必须再次问这个,对我来说具体情况. What's a Schema? A postgresql database has one or more schemas which, in turn, contain one or more postgresql objects (tables, procedures, types, etc). SimpleConnectionPoolを利用してみます。. index; modules | Psycopg 2. PoolError: trying to put unkeyed connection - not sure why this is happeni. We use cookies for various purposes including analytics. ThreadedConnectionPool(minconn, maxconn, *args, **kwargs)¶ A connection pool that works with the threading module. Para melhor organizar o código, criei uma classe com os métodos. And trust me - this is database server that is very busy. • connection (psycopg2. utils import db_url_to_params. if _sa_class is not None and isinstance (statement, _sa_class):. Столкнулся с ошибкой, которую не могу уже некоторое время побороть. from pysimplesoap. Title: Allow updating `modules list` without updating modules: Priority: feature: Status: resolved: Superseder: Nosy List: ced, coogor, jesteve, pokoli, reviewbot. Spark Streaming连接kafka测试 - 在上次使用了下kafka,在此测试下CentOS 7中Spark streaming连接kafka,并把数据传入postgresql中一、环境部署安装python3. Summary: Gunicorn will fork its workers after the psycopg2 connection pool has started multiplying connections to postgresql. 3、kafka,具体可以参考我前面的文章二、启动相应程序启动Zooke. For psycopg2 is 2, i. UNICODEARRAY) except ImportError: # Python 3 import urllib. class psycopg2. GoDataDriven PROUDLY PART OF THE XEBIA GROUP @gglanzani {nielszeilemaker,giovannilanzani}@godatadriven. dataproviders. execute('select r. Basic module usage¶. Other interesting features of the adapter are that if you are using the PostgreSQL array data type, Psycopg will automatically convert a result using that data type to a Python list. This module offers a few pure Python classes implementing simple connection pooling directly in the client application. I have since started using ThreadedConnectionPool and switched to threads (with processes I keep getting psycopg2. connection_poo. Tienes que tener una version mas reciente de pip. class class psycopg2. maxconn for psycopg2. python psycopg2 连接pg 建立连接池的更多相关文章 高性能网络编程(一)----accept建立连接 编写服务器时,许多程序员习惯于使用高层次的组件. Se instalaron de forma automática los siguientes paquetes y ya no son necesarios. ThreadedConnectionPool(minconn, maxconn, *args, **kwargs) 一个连接池与线程模块一起工作。 注意这个池类可以安全地应用在多线程应用程序中。. ThreadedConnectionPool(minconn, maxconn, *args, **kwargs) A connection pool that works with the threading module. Basically, I set up my local Postgres server and. __name__() 。 模块列表. PYODBC to Pandas - DataFrame not working - Shape of passed values is (x,y), indices imply (w,z) I used pyodbc with python before but now I have installed it on a new machine ( win 8 64 bit, Python 2. Psycopg2’s ThreadedConnectionPool It is also a subclass of the AbstractConnectionPool class and implements methods defined in it. parse as urlparse import psycopg2 from psycopg2. You can also save this page to your account. Added the new psycopg2. GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together. GitHub Gist: instantly share code, notes, and snippets. class class psycopg2. This is not on by default because this is not a psycopg2 package. UNICODEARRAY) except ImportError: # Python 3 import urllib. Retry decorator. This module offers a few pure Python classes implementing simple connection pooling directly in the client application. connection_poo. All gists Back to GitHub. Introduction¶. psycopg2のコネクションプーリングは psycopg2. > I use pooler to limit requests to DB. :py:mod:`postgres` is in the `public domain`_. from psycopg2 import connect from pq import PQ conn = connect ('dbname=example user=postgres') pq = PQ (conn) For multi-threaded operation, use a connection pool such as psycopg2. 1 连接数据库系统 ? 在数据库客户端需要建立一条与数据库系统的“连接connection”, 以便与其通信,完成SQL执行和查询等操作。. Transaction Handling with Psycopg2 06 Dec 2017. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. 0' # A Helper # ===== # Heroku gives us an URL, psycopg2 wants a DSN. extras from psycopg2. I have since started using ThreadedConnectionPool and switched to threads (with processes I keep getting psycopg2. Вполне можно использовать простейший штатный пул подключений от psycopg2. These mean that you have a connection that is not doing any active work (so it just sits on some resources), but it keeps all the locks it obtained earlier for however long the transaction will keep on going. python psycopg2 连接pg 建立连接池 摘要:# -*- coding: utf-8 -*-from psycopg2. Столкнулся с ошибкой, которую не могу уже некоторое время побороть. :py:mod:`postgres` is in the `public domain`_. import threading. By default, session cookies will be valid on all subdomains of SERVER_NAME. ThreadConnectionPool for DB connection pooling and only cursor. server import SoapDispatcher, SOAPHandler from BaseHTTPServer import HTTPServer import logging import time,random,datetime,pytz,sys,threading from datetime import timedelta #DB import psycopg2, psycopg2. index:: pair: Connection; Pooling. Click the linked icons to find out why. Здравствуйте! Разбираюсь с контекстными вызовами. ThreadedConnectionPool. sectionauthor:: Daniele Varrazzo. How to reuse database connection in Flask If you want to do it yourself though this is exactly the problem that psycopg2. this allows "import psycopg2" to work. serving from. ThreadedConnectionPool(minconn, maxconn, *args, **kwargs) 一个连接池与线程模块一起工作。 注意这个池类可以安全地应用在多线程应用程序中。. extensions) Time objects Adaptation Time Zones Time zones Fractional Time() (in module psycopg2). Basically, I am trying to load data in parallel using ThreadedConnectionPool. Вполне можно использовать простейший штатный пул подключений от psycopg2. Note: This pool class can be safely used in multi-threaded applications. Psycopg2 Connection Pool. connection_created. org F-Secure Corporation PostgreSQL Conference East 2011 CC-BY. Programming with Python and PostgreSQL Peter Eisentraut [email protected] from multiprocessing import Process. The following are code examples for showing how to use psycopg2. Click the linked icons to find out why. Its main features are the complete implementation of the Python DB API 2. execute('select r. Psycopg - PostgreSQL database adapter for Python¶. Psycopg2 is a DB API 2. py, me deparei com um problema de performance relacionado a operações com banco. e is my > observed behavior a bug or a feature? You should ask the author[s] of "psycopg2" about the supposed behavior. 4 psycopg2。最佳答案pg_class存储所有必需的信息。执行下面的查询将返回用户定义的表作为列表中的元组conn = psycopg2. py仔细阅读一番,就会发现其实逻辑很简单。 class ThreadedConnectionPool(AbstractConnectionPool): """A connection pool that works with the threading module. Summary: Gunicorn will fork its workers after the psycopg2 connection pool has started multiplying connections to postgresql. dataproviders. Вполне можно использовать простейший штатный пул подключений от psycopg2. class psycopg2. 模块列表; 函数列表. 鑑於安全性的理由,您不應使用標準 TCP 通訊端將 App Engine 應用程式連線至 Cloud SQL 執行個體。App Engine 支援透過連接器連接 Cloud SQL 執行個體。以下範例針對 SQLAlchemy (適用於 MySQL) 與 psycopg2 (適用於 PostgresSQL) 使用 PyMySQL 套件:. As performance matters, I am using a ThreadedConnectionPool from psycopg2. Após construir uma API e integrar outras duas com o web. This module offers a few pure Python classes implementing simple connection pooling directly in the client application. >>> db = pypgwrap. python psycopg2 连接pg 建立连接池 摘要:# -*- coding: utf-8 -*-from psycopg2. ThreadedConnectionPool) – psycopg2 pool object • node_factory (object) – Factory class for creating node objects (default: libtree. At a bare minimum, there are only two things that need to be done in order to make Flask work with subdomains: set the SERVER_NAME config value to :. pool – Connections pooling¶. Even if in uwsgi. ini there is threads=1, and only processes are used for concurrency. In general, prepared statements do not provide significant performance improvements in PostgreSQL. Niels Zeilemaker (GoDataDriven): "Embarrassingly parallel database calls with Python" Abstract: Have you ever squeezed you SQL queries to the last millisecond,…. ThreadedConnectionPool 你可能需要使用 utf-8 编码来确定你的数据库是否已经创建。. parse as urlparse import psycopg2 from psycopg2. To use in its simplest form, do (example using psycopg2 and assuming that dsns is a list containing your databases' connection strings) n = 20 # maximum connections per pool pools = [psycopg2. $ pip install psycopg2-binary The binary package is a practical choice for development and testing but in production it is advised to use the package built from sources. It is designed for multi-threaded applications and manages its own connection pool. extensions import UNICODE, UNICODEARRAY, register_type from psycopg2. Database Preliminaries. > I use pooler to limit requests to DB. 32-38 linux-headers-2. > *supposed* to be the correct? Should a psycopg2 pool keep connections > open when returned to the pool (if closed is False), or should it > close them as long as there is more than minconn open? i. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. pool Creating new PostgreSQL connections can be an expensive operation. connection) – psycopg2 connection object • pool (psycopg2. e is my > observed behavior a bug or a feature? You should ask the author[s] of "psycopg2" about the supposed behavior. Programming with Python and PostgreSQL 1. Carl Bordum Hansen carlbordum @magenta-aps Copenhagen, Denmark. py仔细阅读一番,就会发现其实逻辑很简单。 class ThreadedConnectionPool(AbstractConnectionPool): """A connection pool that works with the threading module. GitHub Gist: instantly share code, notes, and snippets. >>> db = pypgwrap. pool import ThreadedConnectionPool,SimpleConnectionPool,PersistentConnectionPool from constant. pool import ThreadedConnectionPool. The following are code examples for showing how to use psycopg2. :py:mod:`postgres` is in the `public domain`_. pool () Examples. connection_created. index:: pair: Connection; Pooling. ThreadedConnectionPool. connection) – psycopg2 connection object • pool (psycopg2. threadsafety¶ Integer constant stating the level of thread safety the interface supports. Creating new PostgreSQL connections can be an expensive operation. Raoul Duke I use psycopgreen for gevent and psycopg2 and it works fine. Because of this, several web server processes will clobber each other's connections to postgresql. dev0 documentation ThreadedConnectionPool (class in psycopg2. pool = ThreadedConnectionPool (1, 20, database = 'd2qn0biqr26ulk', user = 'ybpwrikucwedph',. @Lance: idle in transaction connections are one of the worst things you can have. server import SoapDispatcher, SOAPHandler from BaseHTTPServer import HTTPServer import logging import time,random,datetime,pytz,sys,threading from datetime import timedelta #DB import psycopg2, psycopg2. class psycopg2. Decidi implementar um pool de conexões com ThreadedConnectionPool, já que estou utilizando o driver psycopg2 e PostgreSQL como SGBD. This module offers a few pure Python classes implementing simple connection pooling directly in the client application. 基本上,我设置了我的本地Postgres服务器,需要做成千上万的查询,所以我使用了Python psycopg2package. from psycopg2 import connect from pq import PQ conn = connect ('dbname=example user=postgres') pq = PQ (conn) For multi-threaded operation, use a connection pool such as psycopg2. connection() >>> with db. ThreadedConnectionPool. > > As performance matters, I am using a ThreadedConnectionPool from > > psycopg2. 问题:有时,在并发请求期间,过程调用结果混淆,代码正在查询procedure_1但是正在获取procedure_2的结果(反之亦然,另一个并发客户端). pool` -- Connections pooling =====. How to reuse database connection in Flask If you want to do it yourself though this is exactly the problem that psycopg2. Вполне можно использовать простейший штатный пул подключений от psycopg2. cursor() as c:. from psycopg2. exe 18:19 3. Databases are essential to most applications, however most database interaction is often overlooked by Python developers who use higher level libraries like Django or SQLAlchemy. conf中的设置为 db_name = db_user = openerp db_password = openerp 用pgadmin3登陆PostgreSQL没有问题。 但是,每次用openerp-client都是显示,账套无法连接到服务器,确定按钮是灰色的无法点击。. ''' import contextlib import doctest import json import os import pkgutil import random import time import click import flask import psycopg2 import sqlalchemy import subprocess import sys import threading import traceback import unittest import werkzeug. Столкнулся с ошибкой, которую не могу уже некоторое время побороть. class psycopg2. To create and configure the queue table, call the create() method. module:: psycopg2. extras import RealDictCursor from psycopg2. pool - Connections pooling¶. Honestly I would keep it as simple as possible. 32-38-generic. 51k threads, 5. 0 specification and the thread safety (several threads can share the same connection). Psycopg2’s ThreadedConnectionPool It is also a subclass of the AbstractConnectionPool class and implements methods defined in it. Python psycopg2 模块, pool() 实例源码. SQLALchemy - SQLALchemyされたスレッドとgevent-psycopg2正しく動作するようgevent-psycopg2 。 QueuePoolクラスはthreadingモジュールを内部的に使用してロックするので、 gevent-psycopg2がpsycopg2緑色にしても、猿のパッチが必要です。 例ではpsycopg2 接続プーリングの例がgeventます. Is is described in README in more details. They are extracted from open source Python projects. – eatmeimadanish Oct 11 at 20:02. Hi Gents, I'm currently setting up a demo database on a local test system, and run into the following dump: ----- opensuse:/home/tryton # python /usr/share/doc. extensions). One other interesting feature of the driver is that if you use the PostgreSQL array data type, Psycopg2 will automatically convert a result containing that data type to a Python lis. Вполне можно использовать простейший штатный пул подключений от psycopg2. To create and configure the queue table, call the create() method. When gunicorn forks new process they will copy these connections. get_connection(). Cloud SQL is a fully managed database service that makes it easy to set up, maintain, manage, and administer your relational databases on Google Cloud Platform. 0' # A Helper # ===== # Heroku gives us an URL, psycopg2 wants a DSN. module:: psycopg2. $ pip install psycopg2-binary The binary package is a practical choice for development and testing but in production it is advised to use the package built from sources. callproc用于查询数据库. In general, prepared statements do not provide significant performance improvements in PostgreSQL. 在openerp-server. module:: psycopg2. connection_pool: cls. Cloud SQL is a fully managed database service that makes it easy to set up, maintain, manage, and administer your relational databases on Google Cloud Platform. pool import ThreadedConnectionPool pool = ThreadedConnectionPool(5,100,"dbname=你的数据库名 user=用户名 password=密码 host=主机名 port=端口号") #创建连接池连接 conn= pool. class psycopg2. The actual pool implementation is psycop2g's built-in ThreadedConnectionPool, which handles thread safety for the pool instance, as well as simple dead connection testing when connections are returned. ThreadedConnectionPool(0, 4, conninfo) huey = Postgres(connection_pool=pool)) @huey. pool) threadsafety (in module psycopg2) TIME (in module psycopg2. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. conf中的设置为 db_name = db_user = openerp db_password = openerp 用pgadmin3登陆PostgreSQL没有问题。 但是,每次用openerp-client都是显示,账套无法连接到服务器,确定按钮是灰色的无法点击。. ThreadedConnectionPool(minconn, maxconn, *args, **kwargs). Even if in uwsgi. connect(conn_string) cursor = conn. PYODBC to Pandas - DataFrame not working - Shape of passed values is (x,y), indices imply (w,z) I used pyodbc with python before but now I have installed it on a new machine ( win 8 64 bit, Python 2. 模块列表; 函数列表. python psycopg2 连接pg 建立连接池 utf-8 -*-from psycopg2. Após construir uma API e integrar outras duas com o web. At a bare minimum, there are only two things that need to be done in order to make Flask work with subdomains: set the SERVER_NAME config value to :. Psycopg - PostgreSQL database adapter for Python¶. Is there any way to detect if my application reconnect to db (pgbouncer) on each client request? Is there any way to detect if my application reconnect to db (pgbouncer) on each client request?. 基本上,我设置了我的本地Postgres服务器,需要做成千上万的查询,所以我使用了Python psycopg2package. Psycopg2 is a DB API 2. from pysimplesoap. All gists Back to GitHub. – eatmeimadanish Oct 11 at 20:02. ''' import contextlib import doctest import json import os import pkgutil import random import time import click import flask import psycopg2 import sqlalchemy import subprocess import sys import threading import traceback import unittest import werkzeug. connection_poo. pool import ThreadedConnectionPool,SimpleConnectionPool,PersistentConnectionPool from constant. Python psycopg2 模块, __name__() 实例源码 我们从Python开源项目中,提取了以下 33 个代码示例,用于说明如何使用 psycopg2. 0-compliant PostgreSQL driver that is under active development. sectionauthor:: Daniele Varrazzo. This module offers a few pure Python classes implementing simple connection pooling directly in the client application. Programming with Python and PostgreSQL 1. $ pip install psycopg2-binary The binary package is a practical choice for development and testing but in production it is advised to use the package built from sources. To use in its simplest form, do (example using psycopg2 and assuming that dsns is a list containing your databases’ connection strings) n = 20 # maximum connections per pool pools = [psycopg2. I have modified the config file for both dbname and time xone. Note: This pool class can be safely used in multi-threaded applications. UNICODEARRAY) except ImportError: # Python 3 import urllib. Interface (mode=None, cache=None) ¶. PersistentConnectionPool(minconn, maxconn, *args, ** kwargs) A pool that assigns persistent connections to different. class psycopg2. Introduction¶. table_name (psycopg2. This module offers a few pure Python classes implementing simple connection pooling directly in the client application. > The simple connection pool is not appropriate for concurrent programs: > you should use probably the ThreadedConnectionPool, after checking. extras from psycopg2. Hola a todos, Estoy todavía intentando instalar GNU health pero ahora en ubuntu lucid lynx y me gustaría preguntaros como habéis instalado tryton con todo lo necesario ya que me sigue dando errores de dependencias entre otros. serving from. > I use pooler to limit requests to DB. This prevents to leak connection in the ThreadedConnectionPool of psycopg2. Psycopg is the most popular PostgreSQL database adapter for the Python programming language. pool` -- Connections pooling =====. module:: psycopg2. Database, cache from psycopg2. Creating new PostgreSQL connections can be an expensive operation. extras from psycopg2. Вполне можно использовать простейший штатный пул подключений от psycopg2. > > As performance matters, I am using a ThreadedConnectionPool from > > psycopg2. 我想我应该考虑在程序终止时关闭连接池,我该怎么做?@contextmanager def get_cursor(: global connection_pool if not cls. These mean that you have a connection that is not doing any active work (so it just sits on some resources), but it keeps all the locks it obtained earlier for however long the transaction will keep on going. GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together. pool from huey_pg import PostgresHuey pool = psycopg2. PoolError: trying to put unkeyed connection The strange thing is though that the psycopg2 documentation says that keying a connection is optional so I'm not sure why one is required for the code below. Your connection doesn't fail if it's blocked waiting, and you still get your response faster than checking for open connections. which is incredibly detailed and looks as though I have misunderstood what multiprocessing. connection_created. Je suppose que vous savez gevent-psycopg2 module, ce qui rend psycopg greenlet de l'environnement. python psycopg2 连接pg 建立连接池的更多相关文章 高性能网络编程(一)----accept建立连接 编写服务器时,许多程序员习惯于使用高层次的组件. OK, I Understand. python psycopg2 连接pg 建立连接池,# -*- coding: utf-8 -*-from psycopg2. dataproviders. In order to demonstrate the code in this blog post, we need a database. pool) threadsafety (in module psycopg2) TIME (in module psycopg2. Summary: Gunicorn will fork its workers after the psycopg2 connection pool has started multiplying connections to postgresql. 0 and it is thread safe (threads can share the connections). If decide not use pgbouncer I think pooler is required. Here is an interactive session showing some of the basic commands:. Note This pool class can be safely used in multi-threaded applications. class psycopg2. :py:mod:`postgres` is in the `public domain`_. 0' # A Helper # ===== # Heroku gives us an URL, psycopg2 wants a DSN. sectionauthor:: Daniele Varrazzo. Programming with Python and PostgreSQL 1. ThreadedConnectionPool(minconn, maxconn, *args, **kwargs) 一个连接池与线程模块一起工作。 注意这个池类可以安全地应用在多线程应用程序中。. extras from psycopg2. class psycopg2. Connection pooling is implemented by thinly wrapping a psycopg2 connection object with a pool-aware class. get_connection(). extras import RealDictCursor from psycopg2. Python psycopg2 模块, __name__() 实例源码 我们从Python开源项目中,提取了以下 33 个代码示例,用于说明如何使用 psycopg2. You probably want to make sure your database is created with the utf-8 encoding. ThreadedConnectionPool(minconn, maxconn, *args, ** kwargs) A connection pool that works with the threading module. Psycopg2 Connection Pool. In addition, we have ``docs`` for building the documentation. 8 when running:. In general, prepared statements do not provide significant performance improvements in PostgreSQL. pool, but I also want to have my SQL statements prepared. I'm trying to concurrently insert items into a postgres table via ThreadedConnectionPool, but I keep getting psycopg2. 有人可以解释一下如何在当前数据库中获取表?我正在使用postgresql-8. UNICODEARRAY) except ImportError: # Python 3 import urllib. org F-Secure Corporation PostgreSQL Conference East 2011 CC-BY. The fact-checkers, whose work is more and more important for those who prefer facts over lies, police the line between fact and falsehood on a day-to-day basis, and do a great job. Today, my small contribution is to pass along a very good overview that reflects on one of Trump’s favorite overarching falsehoods. Namely: Trump describes an America in which everything was going down the tubes under  Obama, which is why we needed Trump to make America great again. And he claims that this project has come to fruition, with America setting records for prosperity under his leadership and guidance. “Obama bad; Trump good” is pretty much his analysis in all areas and measurement of U.S. activity, especially economically. Even if this were true, it would reflect poorly on Trump’s character, but it has the added problem of being false, a big lie made up of many small ones. Personally, I don’t assume that all economic measurements directly reflect the leadership of whoever occupies the Oval Office, nor am I smart enough to figure out what causes what in the economy. But the idea that presidents get the credit or the blame for the economy during their tenure is a political fact of life. Trump, in his adorable, immodest mendacity, not only claims credit for everything good that happens in the economy, but tells people, literally and specifically, that they have to vote for him even if they hate him, because without his guidance, their 401(k) accounts “will go down the tubes.” That would be offensive even if it were true, but it is utterly false. The stock market has been on a 10-year run of steady gains that began in 2009, the year Barack Obama was inaugurated. But why would anyone care about that? It’s only an unarguable, stubborn fact. Still, speaking of facts, there are so many measurements and indicators of how the economy is doing, that those not committed to an honest investigation can find evidence for whatever they want to believe. Trump and his most committed followers want to believe that everything was terrible under Barack Obama and great under Trump. That’s baloney. Anyone who believes that believes something false. And a series of charts and graphs published Monday in the Washington Post and explained by Economics Correspondent Heather Long provides the data that tells the tale. The details are complicated. Click through to the link above and you’ll learn much. But the overview is pretty simply this: The U.S. economy had a major meltdown in the last year of the George W. Bush presidency. Again, I’m not smart enough to know how much of this was Bush’s “fault.” But he had been in office for six years when the trouble started. So, if it’s ever reasonable to hold a president accountable for the performance of the economy, the timeline is bad for Bush. GDP growth went negative. Job growth fell sharply and then went negative. Median household income shrank. The Dow Jones Industrial Average dropped by more than 5,000 points! U.S. manufacturing output plunged, as did average home values, as did average hourly wages, as did measures of consumer confidence and most other indicators of economic health. (Backup for that is contained in the Post piece I linked to above.) Barack Obama inherited that mess of falling numbers, which continued during his first year in office, 2009, as he put in place policies designed to turn it around. By 2010, Obama’s second year, pretty much all of the negative numbers had turned positive. By the time Obama was up for reelection in 2012, all of them were headed in the right direction, which is certainly among the reasons voters gave him a second term by a solid (not landslide) margin. Basically, all of those good numbers continued throughout the second Obama term. The U.S. GDP, probably the single best measure of how the economy is doing, grew by 2.9 percent in 2015, which was Obama’s seventh year in office and was the best GDP growth number since before the crash of the late Bush years. GDP growth slowed to 1.6 percent in 2016, which may have been among the indicators that supported Trump’s campaign-year argument that everything was going to hell and only he could fix it. During the first year of Trump, GDP growth grew to 2.4 percent, which is decent but not great and anyway, a reasonable person would acknowledge that — to the degree that economic performance is to the credit or blame of the president — the performance in the first year of a new president is a mixture of the old and new policies. In Trump’s second year, 2018, the GDP grew 2.9 percent, equaling Obama’s best year, and so far in 2019, the growth rate has fallen to 2.1 percent, a mediocre number and a decline for which Trump presumably accepts no responsibility and blames either Nancy Pelosi, Ilhan Omar or, if he can swing it, Barack Obama. I suppose it’s natural for a president to want to take credit for everything good that happens on his (or someday her) watch, but not the blame for anything bad. Trump is more blatant about this than most. If we judge by his bad but remarkably steady approval ratings (today, according to the average maintained by 538.com, it’s 41.9 approval/ 53.7 disapproval) the pretty-good economy is not winning him new supporters, nor is his constant exaggeration of his accomplishments costing him many old ones). I already offered it above, but the full Washington Post workup of these numbers, and commentary/explanation by economics correspondent Heather Long, are here. On a related matter, if you care about what used to be called fiscal conservatism, which is the belief that federal debt and deficit matter, here’s a New York Times analysis, based on Congressional Budget Office data, suggesting that the annual budget deficit (that’s the amount the government borrows every year reflecting that amount by which federal spending exceeds revenues) which fell steadily during the Obama years, from a peak of $1.4 trillion at the beginning of the Obama administration, to $585 billion in 2016 (Obama’s last year in office), will be back up to $960 billion this fiscal year, and back over $1 trillion in 2020. (Here’s the New York Times piece detailing those numbers.) Trump is currently floating various tax cuts for the rich and the poor that will presumably worsen those projections, if passed. As the Times piece reported: