Re: [sqlalchemy] NVARCHAR vs VARCHAR in mssql + convert_unicode='force' Syntax?

2018-10-08 Thread Mike Bayer
Im working on getting off bitbucket but maybe it's an ad blocker? try a private window or something On Mon, Oct 8, 2018 at 6:36 PM Lukasz Szybalski wrote: > > > On Mon, Oct 8, 2018 at 9:56 AM Mike Bayer > wrote: > >> >> >> On Mon, Oct 8, 2018 at 10:28 AM Lukasz Szybalski >> wrote: >> >>> >>>

Re: [sqlalchemy] NVARCHAR vs VARCHAR in mssql + convert_unicode='force' Syntax?

2018-10-08 Thread Lukasz Szybalski
On Mon, Oct 8, 2018 at 9:56 AM Mike Bayer wrote: > > > On Mon, Oct 8, 2018 at 10:28 AM Lukasz Szybalski > wrote: > >> >> I have a query in sqlalchemy like below where I lookup contract# in >> mssql. How do I enforce the varchar instead of nvarchar? I tried >> converting >> my field

Re: Alembic op.alter_column deletes all rows in the database table in error

2018-10-08 Thread Richard
INFO [alembic.runtime.migration] Running upgrade 22923a2e396c -> d4aceba22da2, daily_smart_meter_readings rename customer fk. INFO [sqlalchemy.engine.base.Engine] ALTER TABLE daily_smart_meter_readings RENAME customer_id TO customer_pk INFO [sqlalchemy.engine.base.Engine] {} INFO

Re: Alembic op.alter_column deletes all rows in the database table in error

2018-10-08 Thread Mike Bayer
can you provide SQLAlchemy statement output please, set "level = INFO" under [logger_sqlalchemy] in alembic.ini op.alter_column() does not emit DELETE and nothing in Alembic emits the DELETE statement anywhere except upon the alembic_version table itself. On Mon, Oct 8, 2018 at 10:31 AM Richard

Re: [sqlalchemy] NVARCHAR vs VARCHAR in mssql + convert_unicode='force' Syntax?

2018-10-08 Thread Mike Bayer
On Mon, Oct 8, 2018 at 10:28 AM Lukasz Szybalski wrote: > > I have a query in sqlalchemy like below where I lookup contract# in mssql. > How do I enforce the varchar instead of nvarchar? I tried converting my > field to "str(mycurrent)" but that didn't do anything. Is there some other

Re: [sqlalchemy] NVARCHAR vs VARCHAR in mssql + convert_unicode='force' Syntax?

2018-10-08 Thread Lukasz Szybalski
> I have a query in sqlalchemy like below where I lookup contract# in mssql. How do I enforce the varchar instead of nvarchar? I tried converting my field to "str(mycurrent)" but that didn't do anything. Is there some other spot to force VARCHAR to be sent? >>> >>> >>>

Re: Alembic op.alter_column deletes all rows in the database table in error

2018-10-08 Thread Mike Bayer
Hi there - I have no idea what you are seeing.an actual ALTER COLUMN operation does not delete rows. Of course, if you are using SQLite and batch mode, that might affect things, but you have not specified this. Please specify complete information including log output, stack traces,

Re: [sqlalchemy] Controlling table dependency for flushing

2018-10-08 Thread Mike Bayer
On Sun, Oct 7, 2018 at 7:11 PM Alex Rothberg wrote: > > Okay so I investigated / thought about this further. The issue is that while > I do have a relationship between the various models, some of the > relationships are viewonly since I have overlapping fks. > > For example I have a model

Re: Alembic op.alter_column deletes all rows in the database table in error

2018-10-08 Thread Richard
Note that if I do the same op.alter_column on another table which has a customer FK, it works fine and does not delete all the rows. On Monday, October 8, 2018 at 1:50:38 PM UTC+1, Richard wrote: > > I have an alembic migration which renames a FK column on a table from > 'customer_id' to

Alembic op.alter_column deletes all rows in the database table in error

2018-10-08 Thread Richard
I have an alembic migration which renames a FK column on a table from 'customer_id' to 'customer_pk'. I used to have more in the migration file but narrowed it down to this code causing all the rows to be deleted. def upgrade(): op.alter_column( 'daily_smart_meter_readings',