You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This may be an issue with me not understanding fixtures and/or SQLAlchemy, but any assistance would be great!
I have some data dumped from an MS SQL DB, which is using BIT fields for true/false. I'm trying to load it into a PostgreSQL DB for testing. The data is exported by getting the records (via SQLAlchemy), and then looping over them and generating each dict thus:
def as_dict(r):
d = {}
for c in r.__table__.columns:
o = getattr(r, c.name)
d[c.name]= o
return d
That works great, properly formats UUIDs and date/times. However, the bit fields come out as 'true' or 'false.' While that is what they are being used as, this then creates issues later. When I try to load them into the PG DB (again, via Flask-Fixtures), I get an exception of:
sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) column "isActive" is of type bit but expression is of type boolean
If I change the true/false entries to 1/0 in the Yaml file, I then get:
sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) column "isActive" is of type bit but expression is of type integer
Is there a way to mark them such that Flask-Fixtures will turn them back into Bit objects before it tries to insert them? Does Flask-Fixtures introspect on the column
I realize the proper answer here is "convert them to boolean fields," but this is a legacy database, and quick-and-dirty changes to the schema would not happen soon. :)
This may well be an issue with SQLAlchemy, as it seems it converts from the bit field to a true/false value when selecting, but then does not convert back when inserting the value.
How DO you pass a bit object to SQLAlchemy?
The text was updated successfully, but these errors were encountered:
This may be an issue with me not understanding fixtures and/or SQLAlchemy, but any assistance would be great!
I have some data dumped from an MS SQL DB, which is using BIT fields for true/false. I'm trying to load it into a PostgreSQL DB for testing. The data is exported by getting the records (via SQLAlchemy), and then looping over them and generating each dict thus:
That works great, properly formats UUIDs and date/times. However, the bit fields come out as 'true' or 'false.' While that is what they are being used as, this then creates issues later. When I try to load them into the PG DB (again, via Flask-Fixtures), I get an exception of:
If I change the true/false entries to 1/0 in the Yaml file, I then get:
Is there a way to mark them such that Flask-Fixtures will turn them back into Bit objects before it tries to insert them? Does Flask-Fixtures introspect on the column
I realize the proper answer here is "convert them to boolean fields," but this is a legacy database, and quick-and-dirty changes to the schema would not happen soon. :)
This may well be an issue with SQLAlchemy, as it seems it converts from the bit field to a true/false value when selecting, but then does not convert back when inserting the value.
How DO you pass a bit object to SQLAlchemy?
The text was updated successfully, but these errors were encountered: