I had a similar problem with truncated info in blob fields. This line fixed
for me:
db.executesql('SET TEXTSIZE 2147483647')
right after the DAL connection
On Tuesday, February 10, 2015 at 8:24:19 AM UTC-7, Jose wrote:
>
> Hello everyone
>
> I have the following:
>
> Web2py on Freebsd.
> Database: SQLServer 2008
>
> Connection: web2py <-> pyodbc <-> UnixODBC <-> FreeTDS <-> SQLServer
>
> I'm trying to store some uploaded files into a blob field, instead than on
> the file system.
>
> The table was created by the administrator SQLServer
>
> CREATE TABLE [dbo].[DocumentosBlob](
> [Id] [numeric](18, 0) IDENTITY(1,1) NOT NULL,
> [Nombre] [varchar](50) NULL,
> [Archivo] [varchar](512) NULL,
> [Archivo_Blob] [text] NULL,
> [Archivo_Blob2] [image] NULL
> ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
>
>
>
>
> The adapter defines SQLServer blob fields as IMAGE ('blob': 'IMAGE',).
> Then use for testing the Archivo_Blob2 field is set to IMAGE
> In my model I have:
>
> tb_documentos_blob = db.define_table('DocumentosBlob',
> Field('nombre', length=50),
> Field('archivo', 'upload', uploadfield='archivo_blob2'),
> Field('archivo_blob2', 'blob', writable=False, readable=False),
> migrate=False,
> )
>
>
>
> But it happens that when trying to upload a file upload the following
> error occurs:
>
> *DataError: ('22018', '[22018] [FreeTDS][SQL Server]Operand type clash:
> text is incompatible with image (206) (SQLExecDirectW)')*
>
> Then I changed the field, using one type TEXT (Archivo_Blob). The model
> will now be:
>
> tb_documentos_blob = db.define_table('DocumentosBlob',
> Field('nombre', length=50),
> Field('archivo', 'upload', uploadfield='archivo_blob'),
> Field('archivo_blob', 'blob', writable=False, readable=False),
> migrate=False,
> )
>
>
>
> Now it works, I can upload and download files, but only with very small
> files. Tested with 20KB. With one of 250KB upload it, but at download it is
> broken. I imagine that was truncated when stored in the database.
>
> How I can fix this?
>
> Best Regards
> José
>
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.