Package psycopg2
[hide private]
[frames] | no frames]

Source Code for Package psycopg2

 1  """A Python driver for PostgreSQL 
 2   
 3  psycopg is a PostgreSQL_ database adapter for the Python_ programming 
 4  language. This is version 2, a complete rewrite of the original code to 
 5  provide new-style classes for connection and cursor objects and other sweet 
 6  candies. Like the original, psycopg 2 was written with the aim of being very 
 7  small and fast, and stable as a rock. 
 8   
 9  Homepage: http://initd.org/projects/psycopg2 
10   
11  .. _PostgreSQL: http://www.postgresql.org/ 
12  .. _Python: http://www.python.org/ 
13   
14  :Groups: 
15    * `Connections creation`: connect 
16    * `Value objects constructors`: Binary, Date, DateFromTicks, Time, 
17      TimeFromTicks, Timestamp, TimestampFromTicks 
18  """ 
19  # psycopg/__init__.py - initialization of the psycopg module 
20  # 
21  # Copyright (C) 2003-2004 Federico Di Gregorio  <fog@debian.org> 
22  # 
23  # This program is free software; you can redistribute it and/or modify 
24  # it under the terms of the GNU General Public License as published by the 
25  # Free Software Foundation; either version 2, or (at your option) any later 
26  # version. 
27  # 
28  # This program is distributed in the hope that it will be useful, but 
29  # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY 
30  # or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License 
31  # for more details. 
32   
33  # Import modules needed by _psycopg to allow tools like py2exe to do 
34  # their work without bothering about the module dependencies. 
35  #  
36  # TODO: we should probably use the Warnings framework to signal a missing 
37  # module instead of raising an exception (in case we're running a thin 
38  # embedded Python or something even more devious.) 
39   
40  import sys, warnings 
41  if sys.version_info[0] >= 2 and sys.version_info[1] >= 3: 
42      try: 
43          import datetime as _psycopg_needs_datetime 
44      except: 
45          warnings.warn( 
46              "can't import datetime module probably needed by _psycopg", 
47              RuntimeWarning) 
48  if sys.version_info[0] >= 2 and sys.version_info[1] >= 4: 
49      try: 
50          import decimal as _psycopg_needs_decimal 
51      except: 
52          warnings.warn( 
53              "can't import decimal module probably needed by _psycopg", 
54              RuntimeWarning) 
55  from psycopg2 import tz 
56  del sys, warnings 
57   
58  # Import the DBAPI-2.0 stuff into top-level module. 
59   
60  from _psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID 
61   
62  from _psycopg import Binary, Date, Time, Timestamp 
63  from _psycopg import DateFromTicks, TimeFromTicks, TimestampFromTicks 
64   
65  from _psycopg import Error, Warning, DataError, DatabaseError, ProgrammingError 
66  from _psycopg import IntegrityError, InterfaceError, InternalError 
67  from _psycopg import NotSupportedError, OperationalError 
68   
69  from _psycopg import connect, apilevel, threadsafety, paramstyle 
70  from _psycopg import __version__ 
71   
72  __all__ = [ k for k in locals().keys() if not k.startswith('_') ] 
73