Thank you for the answer, but how it can help...
I tried, but I NEED autoincrement (SERIAL in postgres), NO NEED primary key 
on this, particular column.

Also I tried with Sequence and without autoincrement:
Column('id', BIGINT, sa.Sequence('test_seq'), autoincrement=False, 
nullable=False)
no result too.
I *need* to get:
[sql] id BIGSERIAL
but *got*:
[sql] id BIGINT

I found some *workaround*, but *with warning*:
t = Table(
    'outputs', metadata,
    Column('id', BIGINT, primary_key=True, autoincrement=True, 
nullable=False)
    # Partitioning columns
    Column('run_id', None, ForeignKey('runs.id', onupdate='CASCADE', 
ondelete='CASCADE'), nullable=False, index=True),
    Column('hotel', Integer, nullable=False),
    sa.PrimaryKeyConstraint('id', 'hotel', 'run_id'),
    postgresql_partition_by='range(hotel, run_id)'
)
in this case I got exactly what I want:
CREATE TABLE me_hotels_bc_fb_prediction_steps_outputs (
id BIGSERIAL NOT NULL, 
run_id INTEGER NOT NULL, 
hotel INTEGER NOT NULL, 
PRIMARY KEY (id, hotel, run_id), 
FOREIGN KEY(run_id) REFERENCES runs (id) ON DELETE CASCADE ON UPDATE CASCADE
)
 PARTITION BY range(hotel, run_id)

*warning*:
sqlalchemy/sql/schema.py:3615: SAWarning:

Table 'outputs' specifies columns 'id' as primary_key=True, not matching 
locally specified columns 'id', 'hotel', 'run_id'; setting the current 
primary key columns to 'id', 'hotel', 'run_id'. This warning may become an 
exception in a future release

вторник, 29 сентября 2020 г. в 21:05:47 UTC+4, Mike Bayer: 

> set autoincrement=False in the Column definition
>
> Column('id', BIGINT, autoincrement=False)
>
>
>
> On Tue, Sep 29, 2020, at 3:49 PM, Павел Фролов wrote:
>
> Hi all,
>
> I need just autoincrement without primary key, like:
>
> CREATE TABLE test (
>     id BIGSERIAL NOT NULL,
>     run_id INTEGER NOT NULL
> );
>
> How it's do with sqlalchemy core?
>
> I tried:
>
> sa.Column('id', sa.BIGINT(), sa.Sequence('test_seq')),
> or
> sa.Column('id', sa.BIGINT(), autoincrement=True),
> ->
> id BIGINT,
> (no serial)
>
> I see in docs that autoincrement can be only with primary key.
>
> I asked docs and google - can not find solution.
>
>
> --
> SQLAlchemy - 
> The Python SQL Toolkit and Object Relational Mapper
>  
> http://www.sqlalchemy.org/
>  
> To post example code, please provide an MCVE: Minimal, Complete, and 
> Verifiable Example. See http://stackoverflow.com/help/mcve for a full 
> description.
> --- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sqlalchemy+...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sqlalchemy/4629a9b3-3a8e-47b8-8d9a-580242e81d9fn%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/sqlalchemy/4629a9b3-3a8e-47b8-8d9a-580242e81d9fn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
>
>

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/f8a2df2f-05ff-49da-80ef-8eb71aa326a1n%40googlegroups.com.

Reply via email to