How can I insert image in HTML from database?

588 views
Skip to first unread message

Константин Комков

unread,
Aug 2, 2019, 9:50:41 AM8/2/19
to web2py-users
I do like that:
row = db().select(db.recipes.IMAGE).first()
image
= '<img src="'+URL('default','download',args=row.file)+'"/>'
I get error:

Версия

web2py™Version 2.18.5-stable+timestamp.2019.04.08.04.22.03
PythonPython 3.7.3: C:\Python\python.exe (prefix: C:\Python)

Traceback

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
Traceback (most recent call last):
File "C:\Users\kkomkov.TIMACAD\Desktop\web2py\gluon\packages\dal\pydal\objects.py", line 116, in __getattr__
return self.__getitem__(k)
File "C:\Users\kkomkov.TIMACAD\Desktop\web2py\gluon\packages\dal\pydal\objects.py", line 103, in __getitem__
raise KeyError(key)
KeyError: 'file'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\kkomkov.TIMACAD\Desktop\web2py\gluon\restricted.py", line 219, in restricted
exec(ccode, environment)
File "C:\Users\kkomkov.TIMACAD\Desktop\web2py\applications\Recipes\controllers/default.py", line 176, in <module>
File "C:\Users\kkomkov.TIMACAD\Desktop\web2py\gluon\globals.py", line 421, in <lambda>
self._caller = lambda f: f()
File "C:\Users\kkomkov.TIMACAD\Desktop\web2py\applications\Recipes\controllers/default.py", line 12, in index
recipes = selectRecipes()
File "C:\Users\kkomkov.TIMACAD\Desktop\web2py\applications\Recipes\controllers/default.py", line 111, in selectRecipes
image = '<img src="'+URL('default','download',args=row.file)+'"/>'
File "C:\Users\kkomkov.TIMACAD\Desktop\web2py\gluon\packages\dal\pydal\objects.py", line 118, in __getattr__
raise AttributeError
AttributeError

Error snapshot help

AttributeError()

inspect attributes

Frames

File C:\Users\kkomkov.TIMACAD\Desktop\web2py\gluon\packages\dal\pydal\objects.py in __getattr__ at line 118 код аргументы переменные

Function argument list

(self=<Row {}>, k='file')

Code listing
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.

def __getattr__(self, k):
try:
return self.__getitem__(k)
except KeyError:
raise AttributeError


def __copy__(self):
return Row(self)
Variables
  • builtinAttributeError <class 'AttributeError'>
  • If I do like that:
  • rows = db().select(db.recipes.ALL)
    for row in rows:
       
    if row.recipes.IMAGE is None:
            image
    = ''
       
    else:
            image
    = '<img src="'+URL('default','download',args=row.recipes.IMAGE)+'"/>'
  • I get HTML without image:
  • <img src="/Recipes/default/download/%3Cfdb.fbcore.BlobReader%20object%20at%200x04E09C50%3E"/>

António Ramos

unread,
Aug 2, 2019, 10:04:26 AM8/2/19
to web...@googlegroups.com
what is your model ?

--
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 web2py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/a782e7f9-ff3d-4d0c-affb-5f80bd94f480%40googlegroups.com.

Константин Комков

unread,
Aug 2, 2019, 11:33:33 AM8/2/19
to web2py-users
What do you want to know?
tables.py
db.define_table(
   
'recipes',
   
Field('NAME',length=512),
   
Field('IMAGE'),
    migrate
=False
)
It's my database connection in db.py:
db = DAL('firebird://sysdba:masterkey@localhost/C:/HR.fdb', ignore_field_case=True, entity_quoting=False, pool_size=1, migrate_enabled=False, db_codec='UTF-8')


António Ramos

unread,
Aug 2, 2019, 12:52:16 PM8/2/19
to web...@googlegroups.com
maybe -> Field('IMAGE', 'upload'),

--
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 web2py+un...@googlegroups.com.

Константин Комков

unread,
Aug 2, 2019, 1:15:30 PM8/2/19
to web2py-users
Didn't work, errors was like in my first message. I had tried it already.

Dave S

unread,
Aug 2, 2019, 7:09:07 PM8/2/19
to web2py-users

You probably have to stream the object in the response.

def getmyblob():
   
import cStringIO
   
import os, shutil
   
# print request
   
if len(request.args) == 0 or not request.args[0]:
     
raise HTTP(404, "unknown file not found")
    row
= db(db.mypics.pname == request.args[0]).select().first()
    blob
= db[somethingsomething].[copyblobltotmpfile]

    dst
= os.path.join(request.env.web2py_path, "application", blob.tmpname)
   
if not os.access(dst, os.F_OK):
           
print dst
           
raise HTTP(404,"funny, that's not here")
    imstat
= os.stat(dst)    filedata=open(dst,"rb").read()
    response
.headers['Content-Type']='image/jpeg'
    response
.headers['Content-Length']=imstat.st_size
   
return response.stream(cStringIO.StringIO(filedata))


Then your IMG tag looks like
<IMG src="getmyblob/{{=blobrowid}} alt="image file for {{=blobrowid"}} title="={{blobrowid}}">

Sorry for the hacky look of this, I don't have much experience handling blobs; the code I use is for an image as an ordinary file in the filesystem.  (My app tags pictures transferred from my camera.)

The field type "upload", combined with the default/user/download() function, hides much of this from you, but has something similar under the hood.

Good luck!

/dps






Константин Комков

unread,
Aug 3, 2019, 10:57:15 AM8/3/19
to web2py-users
Dave, I don't understand what means that string:
blob = db[somethingsomething].[copyblobltotmpfile]
Is your example only for '.jpeg' files or for another expansions too? 

Константин Комков

unread,
Aug 5, 2019, 6:03:04 PM8/5/19
to web2py-users
Hello! I can get image like that:
import codecs
base64_data
= codecs.encode(row.recipes.IMAGE.read(), 'base64')
base64_text
= codecs.decode(base64_data, 'ascii')
image
= '<img src="data:image/png;base64, %s" />' % base64_text
Thank all!

Dave S

unread,
Aug 5, 2019, 7:53:29 PM8/5/19
to web2py-users

I think you figured out the important stuff below, but the line you quote is just a hand-waving attempt to suggest retrieving the blob from the DB and putting it in a temporary file.

 /dps

Val K

unread,
Aug 6, 2019, 1:16:10 AM8/6/19
to web2py-users
Set field type to 'upload' as Ramos suggests and
in your first example it should be row.IMAGE instead of row.file

Константин Комков

unread,
Aug 6, 2019, 2:28:43 AM8/6/19
to web2py-users
Val K, it is my table.py file:
db.define_table(
   
'recipes',
   
Field('NAME',length=512),

   
Field('IMAGE','upload'),
    migrate
=False
)
It's code in my default.py file:
row = db().select(db.recipes.IMAGE).first()

image = str(dir(row))
>>>
['IMAGE', '__bool__', '__call__', '__class__', '__contains__', '__copy__', '__delattr__', '__delitem__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattr__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__int__', '__iter__', '__le__', '__long__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'as_dict', 'as_json', 'as_xml', 'clear', 'copy', 'get', 'has_key', 'items', 'iteritems', 'iterkeys', 'itervalues', 'keys', 'pop', 'update', 'values']

image = str(dir(row.IMAGE))
>>>
['_BlobReader__blob_get', '_BlobReader__blobid', '_BlobReader__bytes_read', '_BlobReader__charset', '_BlobReader__closed', '_BlobReader__db_handle', '_BlobReader__ensure_open', '_BlobReader__index', '_BlobReader__is_text', '_BlobReader__mode', '_BlobReader__open', '_BlobReader__opened', '_BlobReader__pos', '_BlobReader__python_charset', '_BlobReader__reset_buffer', '_BlobReader__tr_handle', '__class__', '__del__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__next__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_blob_handle', '_isc_status', 'blob_charset', 'blob_id', 'charset', 'close', 'closed', 'flush', 'get_info', 'is_text', 'mode', 'next', 'read', 'readline', 'readlines', 'seek', 'tell']

I can not do row.file.row.IMAGE


Dave S

unread,
Aug 6, 2019, 10:07:37 PM8/6/19
to web2py-users


On Monday, August 5, 2019 at 11:28:43 PM UTC-7, Константин Комков wrote:
Val K, it is my table.py file:
db.define_table(
   
'recipes',
   
Field('NAME',length=512),
   
Field('IMAGE','upload'),
    migrate
=False
)
It's code in my default.py file:
row = db().select(db.recipes.IMAGE).first()

image = str(dir(row))
>>>

row.keys() is more interesting than dir(row)
 
image = str(dir(row.IMAGE))
>>>
['_BlobReader__blob_get', '_BlobReader__blobid', '_BlobReader__bytes_read', '_BlobReader__charset', '_BlobReader__closed', '_BlobReader__db_handle', '_BlobReader__ensure_open', '_BlobReader__index', '_BlobReader__is_text', '_BlobReader__mode', '_BlobReader__open', '_BlobReader__opened', '_BlobReader__pos', '_BlobReader__python_charset', '_BlobReader__reset_buffer', '_BlobReader__tr_handle', '__class__', '__del__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__next__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_blob_handle', '_isc_status', 'blob_charset', 'blob_id', 'charset', 'close', 'closed', 'flush', 'get_info', 'is_text', 'mode', 'next', 'read', 'readline', 'readlines', 'seek', 'tell']

I can not do row.file.row.IMAGE


row.file probably doesn't exist, because it would have to be row.keys() (it's not in the attributes, as you've shown), and then looking in a putative row.files for row key or attribute doesn't seem sensible.

I don't have any experience with BLOBs, but I believe default/user/download is able to handle them.

For a file-based upload field, the upload field is a string that default/user/download uses to locate the file. That is, it is the obfuscated file name, and the rest of the path is defined by the uploadfolder value (default, myapp/uploads), as well as uploadseparate and uploadfs.  For BLOBs, you've instead set uploadfield to true.  In my case, the file-base one, the attributes are those of a string, but I don't have to do much with it except return it in hrefs.

default/users/download will use the path name or the blob field to figure out what to stream.  There are times when it is desirable to set up the streaming in your code, and I thought this was one of those times, but Ramos and Val K have pointed out how to use the out-of-the-box tool to do this.

/dps

Константин Комков

unread,
Aug 7, 2019, 5:29:01 AM8/7/19
to web2py-users
Dave S, maybe I don't see the out-of-the-box tool. I did all what were suggest Rumos and Val K like I understood:
row = db().select(db.recipes.IMAGE).first()
image
= '<img src="'+URL('default', 'download', args=row.IMAGE)+'"/>'
and
tables.py
db.define_table(
   
'recipes',
   
Field('NAME',length=512),
   
Field('IMAGE','upload'),
    migrate
=False
)
After that I don't have error, but picture is unavailable.
HTML:
<img src="/Recipes/default/download/%3Cfdb.fbcore.BlobReader%20object%20at%200x07E810D0%3E">
Also I tried do like that:
row = db().select(db.recipes.IMAGE).first()
stream
= row.IMAGE
image
= '<img src="'+URL('default', 'download', args=stream.read())+'"/>'
And I have that HTML:
<img src="/Recipes/default/download/b%27%5Cxff%5Cxd8%5Cxff%5Cxe0%5Cx00%5Cx10JFIF%5Cx00%5Cx01%5Cx01...">

Val K

unread,
Aug 7, 2019, 3:47:05 PM8/7/19
to web2py-users
to make it works, files should be loaded using web2py interface (SQLFORM or programmatically - see the book). As far as I can see you have legacy database with already srored images in it, no? If so you can try to use 'uploadfield' option, i.e. you should have 2 fields in your model (upload and blob type) - the first one will use the second to store file instead of FS - see 'more on uploads' in the DAL chapter

Константин Комков

unread,
Aug 9, 2019, 4:47:52 PM8/9/19
to web...@googlegroups.com
Val K, yes, I have database which contain images. I tried use blob ↓.
I don't know why but if I do like that I have error:
table.py
db.define_table(
   
'recipes',
   
Field('NAME',length=512),

   
Field('IMAGE','blob'),
    migrate
=False
)
and query in controller:
db().select(db.recipes.IMAGE).first()

Версия

web2py™Version 2.18.5-stable+timestamp.2019.04.08.04.22.03
PythonPython 3.7.3: C:\Program Files (x86)\Python37-32\python.exe (prefix: C:\Program Files (x86)\Python37-32)

Traceback

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
Traceback (most recent call last
):
File "C:\web2py\gluon\restricted.py", line 219, in restricted
exec(ccode, environment)
File "C:\web2py\applications\test\controllers/default.py", line 61, in <module>
File "C:\web2py\gluon\globals.py", line 421, in <lambda>
self._caller = lambda f: f
()
File "C:\web2py\applications\test\controllers/default.py", line 9, in index
db().select(db.recipes.IMAGE).first()
File "C:\web2py\gluon\packages\dal\pydal\objects.py", line 2395, in select
return adapter.select(self.query, fields, attributes)
File "C:\web2py\gluon\packages\dal\pydal\adapters\base.py", line 763, in select
return self._select_aux(sql, fields, attributes, colnames)
File "C:\web2py\gluon\packages\dal\pydal\adapters\base.py", line 742, in _select_aux
return processor(rows, fields, colnames, cacheable=cacheable)
File "C:\web2py\gluon\packages\dal\pydal\adapters\base.py", line 306, in parse
for row in rows
File "C:\web2py\gluon\packages\dal\pydal\adapters\base.py", line 303, in <listcomp>
self._parse(
File "C:\web2py\gluon\packages\dal\pydal\adapters\base.py", line 232, in _parse
value = self.parse_value(value, fit, ft, blob_decode)
File "C:\web2py\gluon\packages\dal\pydal\adapters\base.py", line 199, in parse_value
return self.parser.parse(value, field_itype, field_type)
File "C:\web2py\gluon\packages\dal\pydal\parsers\__init__.py", line 100, in parse
return self.registered[field_itype](value, field_type)
File "C:\web2py\gluon\packages\dal\pydal\parsers\__init__.py", line 75, in __call__
return self.call(value, field_type)
File "C:\web2py\gluon\packages\dal\pydal\parsers\__init__.py", line 72, in _call
return self.f(self.parser, value)
File "C:\web2py\gluon\packages\dal\pydal\parsers\base.py", line 37, in _blob
decoded = b64decode(to_bytes(value))
File "C:\web2py\gluon\packages\dal\pydal\_compat.py", line 131, in to_bytes
raise TypeError('Expected bytes')
TypeError: Expected bytes

Error snapshot help

TypeError(Expected bytes)

inspect attributes

Frames

Is it bug of DAL or it's normal?

Dave S

unread,
Aug 9, 2019, 5:35:33 PM8/9/19
to web2py-users



That looks like a Python2 vs Python3 issue.    And it's happening in the _compat.py module, which I believe is for P3 support.

/dps
 

Константин Комков

unread,
Aug 9, 2019, 5:43:49 PM8/9/19
to web...@googlegroups.com
Ok, I will register issue on github.

Val K

unread,
Aug 10, 2019, 7:51:19 AM8/10/19
to web...@googlegroups.com
Try this:

#default.py
def img():
    row
= db(<query based on request.args/vars>).select(db.recipes.IMAGE).first()
   
if row:
       
return response.stream(row.IMAGE)


Usage: =URL( 'default', 'img', args=..., vars=...)

Константин Комков

unread,
Aug 10, 2019, 12:21:35 PM8/10/19
to web2py-users
def img():
    row
= db().select(db.recipes.IMAGE).first()
   
if row:
       
return response.stream(row.IMAGE)
image
= '<img src="'+URL( 'default', 'img')+'"/>'
>>> on HTML page no image.
<img src="/Recipes/default/img"/>



Val K

unread,
Aug 10, 2019, 4:16:38 PM8/10/19
to web2py-users
I believe that any object that has
read(chunk) and close() methods can be streamed. Open the browser console, refresh the page and check for errors

Константин Комков

unread,
Aug 10, 2019, 4:30:37 PM8/10/19
to web2py-users
In console was printed - GET http://127.0.0.1:8000/Recipes/default/img 500 (Server Error).

Константин Комков

unread,
Aug 10, 2019, 4:37:14 PM8/10/19
to web2py-users
Hmm, I restart web2py and now message is - GET http://127.0.0.1:8000/Recipes/default/img 404 (NOT FOUND).

Val K

unread,
Aug 10, 2019, 5:22:10 PM8/10/19
to web2py-users
Remove 'blob' from IMAGE field definition, if it causes an error.

Константин Комков

unread,
Aug 10, 2019, 5:55:41 PM8/10/19
to web2py-users
I use upload becouse if I will do query to blob field I have error and can't load page. In console was written - GET http://127.0.0.1:8000/Recipes/default/img 500 (Server Error). Previos message (GET http://127.0.0.1:8000/Recipes/default/img 404 (NOT FOUND).) was becouse I put img function inside index function.

Val K

unread,
Aug 10, 2019, 6:39:22 PM8/10/19
to web2py-users

I mean revert model to the state when you can retrieve images using base64, i.e. instead of encoding image you can stream it. If row.IMAGE.read() will work, stream will work as well

Val K

unread,
Aug 10, 2019, 6:45:50 PM8/10/19
to web2py-users
Also you can inspect server error using appadmin

Константин Комков

unread,
Aug 10, 2019, 7:01:09 PM8/10/19
to web2py-users
Full code which is work:
def index():
    row
= db().select(db.recipes.IMAGE).first()
   
import codecs
    base64_data
= codecs.encode(row.IMAGE.read(), 'base64')

    base64_text
= codecs.decode(base64_data, 'ascii')

    image
= XML('<img src="data:image/png;base64, %s" class="card-img-top" alt="..."/>' % base64_text)
   
return dict(image=image)
Full code which isn't work:
def index():
    image
= XML('<img src="'+URL( 'default', 'img')+'" class="card-img-top" alt="..."/>')
   
return dict(image=image)


def img():
    row
= db().select(db.recipes.IMAGE).first()
   
if row:
       
return response.stream(row.IMAGE)
Console - (GET http://127.0.0.1:8000/Recipes/default/img 500 (Server Error))

Константин Комков

unread,
Aug 10, 2019, 7:12:26 PM8/10/19
to web...@googlegroups.com
It is from appadmin print screen
1.png

Val K

unread,
Aug 10, 2019, 9:33:05 PM8/10/19
to web2py-users
Under inspect error I mean the following:
You will see all errors that were  - the first is the latest - click on it to see what is going on the server when trying to stream images

Константин Комков

unread,
Aug 11, 2019, 4:23:45 AM8/11/19
to web2py-users
If I have error I show it here. In case when I see error in console - "GET http://127.0.0.1:8000/Recipes/default/img 500 (Server Error)" I don't have errors in (http://127.0.0.1:8000/admin/default/errors/Recipes/old). And if I try go to http://127.0.0.1:8000/Recipes/default/img I don't have error in (http://127.0.0.1:8000/admin/default/errors/Recipes/old) too. On page I have message Server Error.
1.png

Val K

unread,
Aug 11, 2019, 5:42:43 AM8/11/19
to web2py-users
OK, it seems that something is crashing while streaming (db connection or something else). I met the similar problem when I tried to yield records from db using iterselect. Try just 'return row.IMAGE.read()' instead of response.stream(...)

Константин Комков

unread,
Aug 11, 2019, 12:47:41 PM8/11/19
to web2py-users
Val K, that case is work!)
def index():
    image
= XML('<img src="'+URL( 'default', 'img')+'" class="card-img-top" alt="..."/>')
   
return dict(image=image)

def img():
    row
= db().select(db.recipes.IMAGE).first()
   
if row:

       
return row.IMAGE.read()
It seems very strange that return row.IMAGE.read() from img function work, but URL( 'default', args=row.IMAGE.read()) don't work.
I have not one image and get it in cycle. Are there variant use img function for it?
rows = db().select(db.recipes.IMAGE)
   
for row in rows:

Val K

unread,
Aug 12, 2019, 4:52:00 AM8/12/19
to web2py-users
I don’t quite understand what do you mean 'in cycle', do you want to include all images  in one html page?

to make img() more useful you can do this (for example)    

def
img():
        id
=
request.args(0)
    if id:
        row = db(
db.recipes.id == id).select(db.recipes.IMAGE).first()
        if row:
                    return row.IMAGE.read()
        


def index():
    #show the first ten images
    img_list = DIV()
    rows = db().select(db.recipes.id, limitby = (0, 10))
    for row in rows:
        img_list.append(IMG(_src = URL('default', 'img', args = [row.id])))
    return dict(img_list = img_list)


Константин Комков

unread,
Aug 12, 2019, 11:19:03 AM8/12/19
to web2py-users
Yes, I want get from database many images (maybe not all, but 100 or 50 pictures). In your case for creating 1 page I need to do 101 or 51 query to database. I want have one query and transfer row.recipes.IMAGE as variable in img function. Somthing like that (but it's not work):
def index():
    image
= ''

    rows
= db().select(db.recipes.IMAGE)
   
for row in rows:

        image
+= '<img src="'+URL( 'default', 'img', args = [row.recipes.IMAGE])+'" class="card-img-top" alt="..."/>'
    image
= XML(image)
   
return dict(image=image)

def img():
    image
= request.args(0)
   
if image:
       
return image.read()

Val K

unread,
Aug 12, 2019, 1:10:21 PM8/12/19
to web2py-users
100 images per page? What do your images look like? Are these icons? What size?
To prevent db scratching there is Cache-Control

Константин Комков

unread,
Aug 12, 2019, 4:55:42 PM8/12/19
to web2py-users
Size of picture maybe like max size of pictures in instagram. I want to get something like on picture.
1.png

Константин Комков

unread,
Aug 17, 2019, 8:56:21 AM8/17/19
to web2py-users
If I use cache, for example:
def putRecipesInCache():
    recipesCache
= cache.ram('recipes', lambda: db().select(db.recipes.IMAGE), time_expire=60*60*24)
   
return recipesCache


def index():
    rows
= putRecipesInCache()
    image
= ''
   
for row in rows:
       
if row.IMAGE is None:
            image
+= ''
       
else:

           
import codecs
            base64_data
= codecs.encode(row.IMAGE.read(), 'base64')
            base64_text
= codecs.decode(base64_data, 'ascii')

            image
+= '<img src="data:image/png;base64, %s" class="card-img-top" alt="..."/>' % base64_text
   
return XML()

I get error:

Error snapshot help

DatabaseError(('Cursor.read_output_blob/isc_open_blob2:\n- SQLCODE: -904\n- invalid database handle (no active connection)', -904, 335544324))

inspect attributes

Frames

    • File C:\web2py\applications\Recipes\controllers\default.py in index at line 74 код аргументы переменные

    • File C:\web2py\applications\Recipes\controllers\default.py in selectRecipes at line 146 код аргументы переменные

    • File C:\Program Files (x86)\Python37-32\lib\site-packages\fdb\fbcore.py in read at line 4764 код аргументы переменные

    • File C:\Program Files (x86)\Python37-32\lib\site-packages\fdb\fbcore.py in __ensure_open at line 4658 код аргументы переменные

    • File C:\Program Files (x86)\Python37-32\lib\site-packages\fdb\fbcore.py in __open at line 4667 код аргументы переменные

      Function argument list

      (self=<fdb.fbcore.BlobReader object>)

      Code listing
      4662.
      4663.
      4664.
      4665.
      4666.
      4667.
      4668.
      4669.
      4670.
      4671.
                                 bs([ibase.isc_bpb_version1, ibase.isc_bpb_type, 1,
      ibase.isc_bpb_type_stream]))
      if db_api_error(self._isc_status):
      raise exception_from_status(DatabaseError,
      self._isc_status,
      "Cursor.read_output_blob/isc_open_blob2:")
      # Get BLOB total length and max. size of segment
      result = ctypes.cast(ctypes.create_string_buffer(20),
      buf_pointer)
      api.isc_blob_info(self._isc_status, self._blob_handle, 2,

    Val K

    unread,
    Aug 17, 2019, 3:07:02 PM8/17/19
    to web...@googlegroups.com
    I am not sure, but I think that the problem has the same root as in the case of streaming: when lambda is invoked db is already wasted/rotten. So you can try to make a module with function that will fetch the rows from current.db and return them. Then you can import this module in the controller and pass module.function to cache.ram.
    Also I think that the best place for static images in the static folder, not in the db.
    Reply all
    Reply to author
    Forward
    0 new messages