Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for schema qualified tables #35

Open
marcel-meyer opened this issue Apr 12, 2019 · 3 comments
Open

Support for schema qualified tables #35

marcel-meyer opened this issue Apr 12, 2019 · 3 comments

Comments

@marcel-meyer
Copy link

Hi there,
I would like to place my queue table in a schema other than public.
When I set the table arg to a schema qualified table name, the following error occurs:

Traceback (most recent call last):
  File "worker.py", line 139, in <module>
    for job in queue:
  File "/Users/marcel/.pyenv/versions/2.7.15/lib/python2.7/site-packages/pq/__init__.py", line 86, in next
    return QueueIterator.__next__(self)
  File "/Users/marcel/.pyenv/versions/2.7.15/lib/python2.7/site-packages/pq/__init__.py", line 81, in __next__
    return self.queue.get(timeout=self.timeout)
  File "/Users/marcel/.pyenv/versions/2.7.15/lib/python2.7/site-packages/pq/__init__.py", line 176, in get
    cursor, block
  File "/Users/marcel/.pyenv/versions/2.7.15/lib/python2.7/site-packages/pq/utils.py", line 69, in wrapper
    cursor.execute("PREPARE %s AS\n%s" % (name, query), d)
psycopg2.ProgrammingError: syntax error at or near "."
LINE 1: PREPARE _pull_item_fsm.queue_test_fsm.queue AS

Is this possible?
Regards,
Marcel

@malthe
Copy link
Owner

malthe commented Apr 12, 2019

Perhaps a decent workaround would be to issue this command on your connection (through an open cursor):

cursor.execute("SET search_path TO " + schema_name)

But it would be nice to have a schema option.

@riyadparvez
Copy link

Is there any update on this issue?

@ThibTrip
Copy link

ThibTrip commented Apr 18, 2021

Hello @riyadparvez it works on the master (as of writing this reply, version 1.9.1-dev) but not on the current PyPI version (1.9.0).
So if you clone the master and install with pip install . (or pip install -e . for editing the library) inside the cloned folder such a code will work (assuming the postgres schema already exists):

import pq

queue = pq.PQ(conn=conn, # some psycopg2 connection
              schema='queues', table='my_jobs')
queue.create()

Note: I was wondering the same thing and figured this out which is why I replied that late 😛

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants