5

I'm running a PostgreSQL database on a server and I'm trying to connect to it using SQLAlchemy. I found that sqlacodegen was a good tool to generate the MetaData object automatically along with its Tables. But when I try and run sqlacodgen postgresql+psycopg2://username:password@host:5432/dbname, I only get this:

# coding: utf-8
from sqlalchemy import MetaData


metadata = MetaData()

The connection string is definitely correct, and the database is up - I ran a small Python script using that connection string to connect to the database and used execute to run a query on it, and it returns exactly what I expected.

I'm not sure where even to start with debugging this. What could I do to see what's wrong? Is there some sort of requirement that sqlacodegen has that I'm missing?

naiveai
  • 590
  • 2
  • 14
  • 42
  • looks like the question is incomplete. I think you forgot to add the error message. – Arun Balakrishnan Dec 10 '18 at 12:24
  • @ArunBalakrishnan There is none, to clarify. I get the empty file, which I did include in the question. Anyway, this question is quite old now and I can't dig up the scenario I had here. Maybe I should just delete it? – naiveai Dec 10 '18 at 13:44
  • yes, now I see what you mean. I got a similar output and then understood your question. You should keep the question. – Arun Balakrishnan Dec 13 '18 at 09:01

1 Answers1

6

As it turns out this problem was unrelated to sqlacodegen. All the tables in my database are prefixed with dbname. Passing in --schema dbname works.

naiveai
  • 590
  • 2
  • 14
  • 42