~ubuntu-branches/debian/jessie/sqlalchemy/jessie

« back to all changes in this revision

Viewing changes to doc/build/dialects/postgresql.rst

  • Committer: Package Import Robot
  • Author(s): Piotr Ożarowski, Jakub Wilk, Piotr Ożarowski
  • Date: 2013-07-06 20:53:52 UTC
  • mfrom: (1.4.23) (16.1.17 experimental)
  • Revision ID: package-import@ubuntu.com-20130706205352-ryppl1eto3illd79
Tags: 0.8.2-1
[ Jakub Wilk ]
* Use canonical URIs for Vcs-* fields.

[ Piotr Ożarowski ]
* New upstream release
* Upload to unstable
* Build depend on python3-all instead of -dev, extensions are not built for
  Python 3.X 

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
 
15
15
    from sqlalchemy.dialects.postgresql import \
16
16
        ARRAY, BIGINT, BIT, BOOLEAN, BYTEA, CHAR, CIDR, DATE, \
17
 
        DOUBLE_PRECISION, ENUM, FLOAT, INET, INTEGER, INTERVAL, \
18
 
        MACADDR, NUMERIC, REAL, SMALLINT, TEXT, TIME, TIMESTAMP, \
19
 
        UUID, VARCHAR
 
17
        DOUBLE_PRECISION, ENUM, FLOAT, HSTORE, INET, INTEGER, \
 
18
        INTERVAL, MACADDR, NUMERIC, REAL, SMALLINT, TEXT, TIME, \
 
19
        TIMESTAMP, UUID, VARCHAR, INT4RANGE, INT8RANGE, NUMRANGE, \
 
20
        DATERANGE, TSRANGE, TSTZRANGE
20
21
 
21
22
Types which are specific to PostgreSQL, or have PostgreSQL-specific
22
23
construction arguments, are as follows:
23
24
 
24
25
.. currentmodule:: sqlalchemy.dialects.postgresql
25
26
 
 
27
.. autoclass:: array
 
28
 
26
29
.. autoclass:: ARRAY
27
 
    :members: __init__
 
30
    :members: __init__, Comparator
28
31
    :show-inheritance:
29
32
 
 
33
.. autoclass:: Any
 
34
 
 
35
.. autoclass:: All
 
36
 
30
37
.. autoclass:: BIT
31
38
    :members: __init__
32
39
    :show-inheritance:
47
54
    :members: __init__, create, drop
48
55
    :show-inheritance:
49
56
 
 
57
.. autoclass:: HSTORE
 
58
    :members:
 
59
    :show-inheritance:
 
60
 
 
61
.. autoclass:: hstore
 
62
    :members:
 
63
    :show-inheritance:
 
64
 
50
65
.. autoclass:: INET
51
66
    :members: __init__
52
67
    :show-inheritance:
67
82
    :members: __init__
68
83
    :show-inheritance:
69
84
 
70
 
 
71
 
psycopg2 Notes
 
85
Range Types
 
86
~~~~~~~~~~~
 
87
 
 
88
The new range column types founds in PostgreSQL 9.2 onwards are
 
89
catered for by the following types:
 
90
 
 
91
.. autoclass:: INT4RANGE
 
92
   :show-inheritance:
 
93
 
 
94
.. autoclass:: INT8RANGE
 
95
   :show-inheritance:
 
96
 
 
97
.. autoclass:: NUMRANGE
 
98
   :show-inheritance:
 
99
 
 
100
.. autoclass:: DATERANGE
 
101
   :show-inheritance:
 
102
 
 
103
.. autoclass:: TSRANGE
 
104
   :show-inheritance:
 
105
 
 
106
.. autoclass:: TSTZRANGE
 
107
   :show-inheritance:
 
108
 
 
109
The types above get most of their functionality from the following
 
110
mixin:
 
111
 
 
112
.. autoclass:: sqlalchemy.dialects.postgresql.ranges.RangeOperators
 
113
    :members:
 
114
 
 
115
.. warning::
 
116
 
 
117
  The range type DDL support should work with any Postgres DBAPI
 
118
  driver, however the data types returned may vary. If you are using
 
119
  ``psycopg2``, it's recommended to upgrade to version 2.5 or later
 
120
  before using these column types.
 
121
 
 
122
 
 
123
PostgreSQL Constraint Types
 
124
---------------------------
 
125
 
 
126
SQLAlchemy supports Postgresql EXCLUDE constraints via the
 
127
:class:`ExcludeConstraint` class:
 
128
 
 
129
.. autoclass:: ExcludeConstraint
 
130
   :show-inheritance:
 
131
   :members: __init__
 
132
 
 
133
For example::
 
134
 
 
135
  from sqlalchemy.dialects.postgresql import ExcludeConstraint, TSRANGE
 
136
 
 
137
  class RoomBookings(Base):
 
138
 
 
139
      room = Column(Integer(), primary_key=True)
 
140
      during = Column(TSRANGE())
 
141
 
 
142
      __table_args__ = (
 
143
          ExcludeConstraint(('room', '='), ('during', '&&')),
 
144
      )
 
145
 
 
146
psycopg2
72
147
--------------
73
148
 
74
149
.. automodule:: sqlalchemy.dialects.postgresql.psycopg2
75
150
 
76
 
 
77
 
py-postgresql Notes
 
151
py-postgresql
78
152
--------------------
79
153
 
80
154
.. automodule:: sqlalchemy.dialects.postgresql.pypostgresql
81
155
 
82
 
pg8000 Notes
 
156
pg8000
83
157
--------------
84
158
 
85
159
.. automodule:: sqlalchemy.dialects.postgresql.pg8000
86
160
 
87
 
zxjdbc Notes
 
161
zxjdbc
88
162
--------------
89
163
 
90
164
.. automodule:: sqlalchemy.dialects.postgresql.zxjdbc