Code Monkey home page Code Monkey logo

Comments (5)

stas avatar stas commented on June 25, 2024 3

@malthe do you think you can release a new version, because it looks like the tag v1.8.1 is not including the latest changes in the SQL file the @retr0h is mentioning.

@retr0h, the tag v1.8.1 actually does not include the changes, so I think we should just release the master under v1.8.2 and it should solve the issue:
https://github.com/malthe/pq/blob/1.8.1/pq/create.sql

Thanks for being patient with us 🙇 🙈

from pq.

malthe avatar malthe commented on June 25, 2024 1

I have released 1.8.2. Sorry for the wait!

from pq.

retr0h avatar retr0h commented on June 25, 2024

Actually, this looks to be a problem with pip install in general.

[jodewey:~] % mkdir foo
[jodewey:~] % cd foo
[jodewey:~/foo] % virtualenv --no-site-packages .venv
Using base prefix '/Users/jodewey/.pyenv/versions/3.7.6'
New python executable in /Users/jodewey/foo/.venv/bin/python3.7
Also creating executable in /Users/jodewey/foo/.venv/bin/python
Installing setuptools, pip, wheel...
done.
[jodewey:~/foo] % source .venv/bin/activate
[jodewey:~/foo] % pip install pq
Processing /Users/jodewey/Library/Caches/pip/wheels/bb/9a/57/391012c0c104963cc3c6575f90af34d951eb5b123179bfe9c9/pq-1.8.1-py3-none-any.whl
Installing collected packages: pq
Successfully installed pq-1.8.1
[jodewey:~/foo] % find . -name "create.sql"
./.venv/lib/python3.7/site-packages/pq/create.sql
[jodewey:~/foo] % cat ./.venv/lib/python3.7/site-packages/pq/create.sql
do $$ begin

CREATE TABLE %(name)s (
  id          bigserial    PRIMARY KEY,
  enqueued_at timestamptz  NOT NULL DEFAULT current_timestamp,
  dequeued_at timestamptz,
  expected_at timestamptz,
  schedule_at timestamptz,
  q_name      text         NOT NULL CHECK (length(q_name) > 0),
  data        json         NOT NULL
);

end $$ language plpgsql;

create index priority_idx_%(name)s on %(name)s
    (schedule_at nulls first, expected_at nulls first, q_name)
    where dequeued_at is null
          and q_name = '%(name)s';

create index priority_idx_no_%(name)s on %(name)s
    (schedule_at nulls first, expected_at nulls first, q_name)
    where dequeued_at is null
          and q_name != '%(name)s';

drop function if exists pq_notify() cascade;

create function pq_notify() returns trigger as $$ begin
  perform pg_notify(new.q_name, '');
  return null;
end $$ language plpgsql;

create trigger pq_insert
after insert on %(name)s
for each row
execute procedure pq_notify();

from pq.

stas avatar stas commented on June 25, 2024

@retr0h, could you please help us understand what exactly is the issue here?

The error you're getting looks pretty straight-forward:

psycopg2.errors.DuplicateTable: relation "queue" already exists

I recently had to set up pq with django and there's a simple way to work around this:
occrp/id-backend@0e0b5f9#diff-1066dd485a7c75c339cc3bd577b45328

from pq.

retr0h avatar retr0h commented on June 25, 2024

@stas The issue is the create.sql file in the pypi package 1.8.1, does not contain the same contents in the pq repo's master branch.

For some reason when the author tags the repo and creates a release, the create.sql is not being updated.

create.sql:

The file in master branch has conditions in the sql create table if not exists %(name)s, where this schema file would be safe to run multiple times.

The error you're getting looks pretty straight-forward:

psycopg2.errors.DuplicateTable: relation "queue" already exists

I recently had to set up pq with django and there's a simple way to work around this:
occrp/id-backend@0e0b5f9#diff-1066dd485a7c75c339cc3bd577b45328

You are working around the very problem I am discussing in this issue.

from pq.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.