SQLite Forum

Integer becomes blob
Login
I had a similar problem using python 3 and sqlite via apsw:

   ```Python
Python 3.9.5 (tags/v3.9.5:0a7dcbd, May  3 2021, 17:27:52) [MSC v.1928 64 bit (AM
D64)] on win32  
Type "help", "copyright", "credits" or "license" for more information.  
>>> import apsw, datetime, MetaTrader5 as mt5  
>>> from contextlib import closing  
>>> conn=apsw.Connection("C:\\Users\\Administrator\\AppData\\Roaming\\MetaQuotes\\Terminal\\D0E8209F77C8CF37AD8BF550E51FF075\\MQL5\\tgsignals.sqlite")  
>>> conn.setbusytimeout(10000)  
>>> mt5.initialize()  
True  
>>> utc_to = datetime.datetime.now().replace(tzinfo=datetime.timezone.utc).timestamp()  
>>> utc_from = utc_to-300  
>>> ratesm5 = mt5.copy_rates_range("USDJPY", mt5.TIMEFRAME_M5, utc_from, utc_to)  
>>> curbar = ratesm5[0][0]  
>>> curbar  
1636024200  
>>> type(curbar)  
<class 'numpy.int64'>
```
inserting curbar into the 'time' field of table 'equity' led to the following unwanted result:

```Python  
>>> with closing(conn.cursor()) as cursor:  
...     for row in cursor.execute("SELECT time, typeof(time) FROM equity"):  
...         print(row)  
...  
(b'\xa0\xd4\x83a\x00\x00\x00\x00', 'blob')  
(b'\xcc\xd5\x83a\x00\x00\x00\x00', 'blob')  
(b'\xf8\xd6\x83a\x00\x00\x00\x00', 'blob')    
```  

However the simple expedient of substituting *<code>curbar = ratesm5[0][0].item() </code>*for *<code>curbar = ratesm5[0][0]</code>* gave the desired output in the new lines:  

```Python  
>>> with closing(conn.cursor()) as cursor:  
...     for row in cursor.execute("SELECT time, typeof(time) FROM equity"):  
...         print(row)  
...  
(b'\xa0\xd4\x83a\x00\x00\x00\x00', 'blob')  
(b'\xcc\xd5\x83a\x00\x00\x00\x00', 'blob')  
(b'\xf8\xd6\x83a\x00\x00\x00\x00', 'blob')  
(1636030200, 'integer')  
(1636030500, 'integer')  
```  

Hope this helps someone...