Postgres fails to create empty tables
See original GitHub issueCannot init Postgres+psycopg2 database, the codes are basically from docs:
init_engine_and_session_factory(url=db_url)
engine = get_engine()
create_all_tables(engine)
Used latest official docker for Postgres (https://hub.docker.com/_/postgres).
My error:
ProgrammingError: (psycopg2.errors.SyntaxError) type modifier is not allowed for type "text"
LINE 4: data_json TEXT(4294967295) NOT NULL,
^
[SQL:
CREATE TABLE data_v2 (
id SERIAL NOT NULL,
data_json TEXT(4294967295) NOT NULL,
description VARCHAR(255),
experiment_id INTEGER,
time_created BIGINT NOT NULL,
trial_index INTEGER,
generation_strategy_id INTEGER,
PRIMARY KEY (id),
FOREIGN KEY(experiment_id) REFERENCES experiment_v2 (id),
FOREIGN KEY(generation_strategy_id) REFERENCES generation_strategy (id)
)
]
Looks like Text doesn’t accept a length argument with PostgreSQL. https://github.com/facebook/Ax/blob/eb707b168a4e66bc14ac72ba4bbdbc3c69387020/ax/storage/sqa_store/sqa_classes.py#L238
However, same works perfect with with SQLite.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
Create empty table in postgresql - Stack Overflow
You can have a table with no columns, and even with some rows in it: CREATE TABLE nocolumn (dummy INTEGER NOT NULL PRIMARY...
Read more >CREATE TABLE IF ONLY NOT EMPTY RESULT SET
Check if a table is empty after creation and throw an exception if it is. Catch that exception (and do nothing). That rolls...
Read more >Documentation: 15: CREATE TABLE - PostgreSQL
CREATE TABLE will create a new, initially empty table in the current database. The table will be owned by the user issuing the...
Read more >PostgreSQL - CREATE Table - Tutorialspoint
You can verify if your table has been created successfully using \d command, which will be used to list down all the tables...
Read more >PostgreSQL Create Table IF NOT EXISTS - Command Prompt
If a database already has a table with the same name, then a "relation already exists" error will appear in Postgres. To avoid...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It is probably worth mentioning for whoever is bumping into this that another option to make Ax work on Postgres without touching the code locally or switching DB backend altogether, as suggested in https://github.com/sqlalchemy/sqlalchemy/issues/4443 mentioned above by @Jakepodell, is to alter the sqlalchemy compilation rules for the postgres dialect for the TEXT type, directly on client side, or on the code that is supposed to do the initial migration. For example this seems to work fine, tables are created on Postgres and the experiments are logged correctly:
Thanks @Jakepodell !
Actually gonna keep this open, since hopefully we can fix and I want to keep the issue here as a reminder.