Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I use the inet type with Python and postgresql?
    primarykey
    data
    text
    <p>I am writing a python3 program that uses a postgresql database, I am using py-postgresql: <a href="http://python.projects.postgresql.org/" rel="nofollow">http://python.projects.postgresql.org/</a> as the database driver. One table stores IP addresses using the inet type.</p> <p>I have created the following prepared statement:</p> <pre><code>aID = db.prepare('SELECT id FROM a_records WHERE ip = $1 LIMIT 1') </code></pre> <p>When calling aID(ip) I get the following error: </p> <p>(ip is a python string)</p> <pre><code> File "/usr/local/lib/python3.1/dist-packages/postgresql/driver/pq3.py", line 1517, in __call__ c = SingleXactFetch(self, parameters) File "/usr/local/lib/python3.1/dist-packages/postgresql/driver/pq3.py", line 837, in __init__ Output.__init__(self, '') File "/usr/local/lib/python3.1/dist-packages/postgresql/driver/pq3.py", line 622, in __init__ self._init() File "/usr/local/lib/python3.1/dist-packages/postgresql/driver/pq3.py", line 854, in _init STEP() File "/usr/local/lib/python3.1/dist-packages/postgresql/driver/pq3.py", line 2612, in _pq_step self.typio.raise_error(x.error_message, cause = getattr(x, 'exception', Non e)) File "/usr/local/lib/python3.1/dist-packages/postgresql/driver/pq3.py", line 507, in raise_error self.raise_server_error(error_message, **kw) File "/usr/local/lib/python3.1/dist-packages/postgresql/driver/pq3.py", line 498, in raise_server_error raise server_error postgresql.exceptions.BinaryRepresentationError: invalid address family in exte rnal "inet" value CODE: 22P03 LOCATION: File 'network.c', line 218, in network_recv from SERVER RESULT: type: SingleXactFetch parameters: ('139.78.113.1',) STATEMENT: [prepared] sql_parameter_types: ['pg_catalog.inet'] results: (id INTEGER) statement_id: py:0x2ff9a50 string: SELECT id FROM a_records WHERE ip = $1 LIMIT 1 CONNECTION: [idle] client_address: 127.0.0.1/32 client_port: 51563 version: PostgreSQL 8.4.7 on x86_64-pc-linux-gnu, compiled by GCC gcc-4.4.real (Debi an 4.4.5-8) 4.4.5, 64-bit CONNECTOR: [IP4] pq://python:***@127.0.0.1:5432/vdz category: None DRIVER: postgresql.driver.pq3.Driver </code></pre> <p>Can anyone help me debug this and figure out why postgresql is not liking the inet data?</p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload