本文整理汇总了Python中psycopg2.__version__方法的典型用法代码示例。如果您正苦于以下问题:Python psycopg2.__version__方法的具体用法?Python psycopg2.__version__怎么用?Python psycopg2.__version__使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类psycopg2
的用法示例。
在下文中一共展示了psycopg2.__version__方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check6_bsddb3
# 需要导入模块: import psycopg2 [as 别名]
# 或者: from psycopg2 import __version__ [as 别名]
def check6_bsddb3(self):
'''bsddb3 - Python Bindings for Oracle Berkeley DB
requires Berkeley DB
PY_BSDDB3_VER_MIN = (6, 0, 1) # 6.x series at least
'''
self.append_text("\n")
# Start check
try:
import bsddb3 as bsddb
bsddb_str = bsddb.__version__ # Python adaptation layer
# Underlying DB library
bsddb_db_str = str(bsddb.db.version()).replace(', ', '.')\
.replace('(', '').replace(')', '')
except ImportError:
bsddb_str = 'not found'
bsddb_db_str = 'not found'
result = ("* Berkeley Database library (bsddb3: " + bsddb_db_str +
") (Python-bsddb3 : " + bsddb_str + ")")
# End check
self.append_text(result)
示例2: check_fontconfig
# 需要导入模块: import psycopg2 [as 别名]
# 或者: from psycopg2 import __version__ [as 别名]
def check_fontconfig(self):
''' The python-fontconfig library is used to support the Genealogical
Symbols tab of the Preferences. Without it Genealogical Symbols don't
work '''
try:
import fontconfig
vers = fontconfig.__version__
if vers.startswith("0.5."):
result = ("* python-fontconfig " + vers +
" (Success version 0.5.x is installed.)")
else:
result = ("* python-fontconfig " + vers +
" (Requires version 0.5.x)")
except ImportError:
result = "* python-fontconfig Not found, (Requires version 0.5.x)"
# End check
self.append_text(result)
#Optional
示例3: check23_pedigreechart
# 需要导入模块: import psycopg2 [as 别名]
# 或者: from psycopg2 import __version__ [as 别名]
def check23_pedigreechart(self):
'''PedigreeChart - Can optionally use - NumPy if installed
https://github.com/gramps-project/addons-source/blob/master/PedigreeChart/PedigreeChart.py
'''
self.append_text("\n")
self.render_text("""<b>03. <a href="https://gramps-project.org/wiki"""
"""/index.php?title=PedigreeChart">"""
"""Addon:PedigreeChart</a> :</b> """)
# Start check
try:
import numpy
numpy_ver = str(numpy.__version__)
#print("numpy.__version__ :" + numpy_ver )
# NUMPY_check = True
except ImportError:
numpy_ver = "Not found"
# NUMPY_check = False
result = "(NumPy : " + numpy_ver + " )"
# End check
self.append_text(result)
#self.append_text("\n")
示例4: __call__
# 需要导入模块: import psycopg2 [as 别名]
# 或者: from psycopg2 import __version__ [as 别名]
def __call__(self, parser, *a):
version = (
"%(package)s %(version)s\n"
"psycopg2 %(psycopg2version)s\n"
"python-ldap %(ldapversion)s\n"
"Python %(pyversion)s\n"
) % dict(
package=__package__,
version=__version__,
psycopg2version=psycopg2.__version__,
pyversion=sys.version,
ldapversion=ldap.__version__,
)
print(version.strip())
parser.exit()
示例5: inspect_versions
# 需要导入模块: import psycopg2 [as 别名]
# 或者: from psycopg2 import __version__ [as 别名]
def inspect_versions():
from alembic import __version__ as alembic_version
from psycopg2 import __version__ as psycopg2_version
from tornado import version as tornado_version
from sqlalchemy import __version__ as sqlalchemy_version
with open('/etc/os-release') as fo:
distinfos = parse_lsb_release(fo)
return dict(
temboard=__version__,
alembic=alembic_version,
psycopg2=psycopg2_version,
python=python_version(),
pythonbin=sys.executable,
tornado=tornado_version,
sqlalchemy=sqlalchemy_version,
distname=distinfos['NAME'],
distversion=distinfos['VERSION'],
)
示例6: get_summary
# 需要导入模块: import psycopg2 [as 别名]
# 或者: from psycopg2 import __version__ [as 别名]
def get_summary(cls):
"""
Return a diction of information about this database
backend.
"""
summary = {
"DB-API version": "2.0",
"Database SQL type": cls.__name__,
"Database SQL module": "psycopg2",
"Database SQL module version": psycopg2.__version__,
"Database SQL module location": psycopg2.__file__,
}
return summary
示例7: get_summary
# 需要导入模块: import psycopg2 [as 别名]
# 或者: from psycopg2 import __version__ [as 别名]
def get_summary(self):
"""
Return a diction of information about this database
backend.
"""
summary = super().get_summary()
summary.update({
_("Database version"): psycopg2.__version__,
_("Database module location"): psycopg2.__file__,
})
return summary
示例8: check17_pillow
# 需要导入模块: import psycopg2 [as 别名]
# 或者: from psycopg2 import __version__ [as 别名]
def check17_pillow(self):
'''PILLOW
Allows Production of jpg images from non-jpg images in LaTeX documents
#TODO prculley mentions that : And PIL (Pillow) is also used by the
main Gramps ([]narrativeweb and []other reports for image cropping)
as well as [x]editexifmetadata and the
new [x]latexdoc type addons (genealogytree).
#TODO add check for PILLOW to "gramps -v" section
https://github.com/gramps-project/gramps/blob/maintenance/gramps50/gramps/plugins/docgen/latexdoc.py
'''
#self.append_text("\n")
# Start check
try:
import PIL
# from PIL import Image
try:
pil_ver = PIL.__version__
except Exception:
try:
pil_ver = str(PIL.PILLOW_VERSION)
except Exception:
try:
#print(dir(PIL))
pil_ver = str(PIL.VERSION)
except Exception:
pil_ver = "Installed but does not supply version"
except ImportError:
pil_ver = "Not found"
result = "(PILLOW " + pil_ver + ")"
# End check
self.append_text(result)
示例9: setup_mysql
# 需要导入模块: import psycopg2 [as 别名]
# 或者: from psycopg2 import __version__ [as 别名]
def setup_mysql(username, password, host, port):
"""
ModuleNotFoundError: No module named 'MySQLdb'
pip install mysqlclient
Python 2: pip install mysqlclient -> MySQLdb/_mysql.c(29) :
fatal error C1083: Cannot open include file: 'mysql.h': No such file or directory
https://stackoverflow.com/questions/51294268/pip-install-mysqlclient-returns-fatal-error-c1083-cannot-open-file-mysql-h
https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient
pip install "path to the downloaded mysqlclient.whl file"
"""
require_version = '0.9.3' # Dec 18, 2018
install_command = "pip install --upgrade pymysql"
try:
import pymysql
assert pymysql.__version__ >= require_version, install_command
except (ImportError, AssertionError):
sys.exit("Run command: %s" % install_command)
else:
# Run scrapydweb: ModuleNotFoundError: No module named 'MySQLdb'
pymysql.install_as_MySQLdb()
conn = pymysql.connect(host=host, port=int(port), user=username, password=password,
charset='utf8', cursorclass=pymysql.cursors.DictCursor)
cur = conn.cursor()
for dbname in DBS:
if SCRAPYDWEB_TESTMODE:
drop_database(cur, dbname)
# pymysql.err.ProgrammingError: (1007, "Can't create database 'scrapydweb_apscheduler'; database exists")
# cur.execute("CREATE DATABASE IF NOT EXISTS %s CHARACTER SET 'utf8' COLLATE 'utf8_general_ci'" % dbname)
try:
cur.execute("CREATE DATABASE %s CHARACTER SET 'utf8' COLLATE 'utf8_general_ci'" % dbname)
except Exception as err:
if 'exists' in str(err):
pass
else:
raise
cur.close()
conn.close()
示例10: _has_lo64
# 需要导入模块: import psycopg2 [as 别名]
# 或者: from psycopg2 import __version__ [as 别名]
def _has_lo64(conn):
"""Return (bool, msg) about the lo64 support"""
if conn.server_version < 90300:
return (False, "server version %s doesn't support the lo64 API"
% conn.server_version)
if 'lo64' not in psycopg2.__version__:
return (False, "this psycopg build doesn't support the lo64 API")
return (True, "this server and build support the lo64 API")
示例11: test_connect_isolation_level
# 需要导入模块: import psycopg2 [as 别名]
# 或者: from psycopg2 import __version__ [as 别名]
def test_connect_isolation_level(self):
"""
Regression test for #18130 and #24318.
"""
import psycopg2
from psycopg2.extensions import (
ISOLATION_LEVEL_READ_COMMITTED as read_committed,
ISOLATION_LEVEL_SERIALIZABLE as serializable,
)
# Since this is a django.test.TestCase, a transaction is in progress
# and the isolation level isn't reported as 0. This test assumes that
# PostgreSQL is configured with the default isolation level.
# Check the level on the psycopg2 connection, not the Django wrapper.
default_level = read_committed if psycopg2.__version__ < '2.7' else None
self.assertEqual(connection.connection.isolation_level, default_level)
new_connection = connection.copy()
new_connection.settings_dict['OPTIONS']['isolation_level'] = serializable
try:
# Start a transaction so the isolation level isn't reported as 0.
new_connection.set_autocommit(False)
# Check the level on the psycopg2 connection, not the Django wrapper.
self.assertEqual(new_connection.connection.isolation_level, serializable)
finally:
new_connection.close()
示例12: test_correct_extraction_psycopg2_version
# 需要导入模块: import psycopg2 [as 别名]
# 或者: from psycopg2 import __version__ [as 别名]
def test_correct_extraction_psycopg2_version(self):
from django.db.backends.postgresql.base import psycopg2_version
version_path = 'django.db.backends.postgresql.base.Database.__version__'
with mock.patch(version_path, '2.6.9'):
self.assertEqual(psycopg2_version(), (2, 6, 9))
with mock.patch(version_path, '2.5.dev0'):
self.assertEqual(psycopg2_version(), (2, 5))
示例13: GetPrerequisites
# 需要导入模块: import psycopg2 [as 别名]
# 或者: from psycopg2 import __version__ [as 别名]
def GetPrerequisites(info=False):
try:
import psycopg2
if psycopg2.__version__ > "2.4":
return "psycopg2 csv"
else:
if info:
print "psycopg2 too old"
except:
if info:
print "psycopg2 missing"
pass
return None
示例14: test_connect_isolation_level
# 需要导入模块: import psycopg2 [as 别名]
# 或者: from psycopg2 import __version__ [as 别名]
def test_connect_isolation_level(self):
"""
The transaction level can be configured with
DATABASES ['OPTIONS']['isolation_level'].
"""
import psycopg2
from psycopg2.extensions import (
ISOLATION_LEVEL_READ_COMMITTED as read_committed,
ISOLATION_LEVEL_SERIALIZABLE as serializable,
)
# Since this is a django.test.TestCase, a transaction is in progress
# and the isolation level isn't reported as 0. This test assumes that
# PostgreSQL is configured with the default isolation level.
# Check the level on the psycopg2 connection, not the Django wrapper.
default_level = read_committed if psycopg2.__version__ < '2.7' else None
self.assertEqual(connection.connection.isolation_level, default_level)
new_connection = connection.copy()
new_connection.settings_dict['OPTIONS']['isolation_level'] = serializable
try:
# Start a transaction so the isolation level isn't reported as 0.
new_connection.set_autocommit(False)
# Check the level on the psycopg2 connection, not the Django wrapper.
self.assertEqual(new_connection.connection.isolation_level, serializable)
finally:
new_connection.close()
示例15: test_correct_extraction_psycopg2_version
# 需要导入模块: import psycopg2 [as 别名]
# 或者: from psycopg2 import __version__ [as 别名]
def test_correct_extraction_psycopg2_version(self):
from django.db.backends.postgresql.base import psycopg2_version
with mock.patch('psycopg2.__version__', '4.2.1 (dt dec pq3 ext lo64)'):
self.assertEqual(psycopg2_version(), (4, 2, 1))
with mock.patch('psycopg2.__version__', '4.2b0.dev1 (dt dec pq3 ext lo64)'):
self.assertEqual(psycopg2_version(), (4, 2))