facebookarchive/pyaib

Error binding parameter 1 - probably unsupported type.

jfhbrook opened this issue · 6 comments

I'm using this project for a community bot and just started upgrading to v2. This is in part because it looks like my bot doesn't create a sqlite db with v1 (maybe that functionality was shimmed back then?). While I didn't have my bot creating a sqlite db before, now I get this crazy error:

$ python ./moodybot.py
Config Module Loaded.
Loaded Config from moodybot.conf.
Loading Component triggers...
Triggers Loaded
Loading Component channels...
Channel Management Loaded
Loading Component plugins...
Loading Component db...
Sqlite DB Driver Loaded!
Loading Plugin ddg...
/Users/josh/dev/jfhbrook/moodybot/env/lib/python2.7/site-packages/grequests.py:21: RuntimeWarning: Patching more than once will result in the union of all True parameters being patched
  curious_george.patch_all(thread=False, select=False)
Loading Plugin eliza...
Loading Plugin jokes...
Loading Plugin pug...
Loading Plugin reddit...
Loading Plugin source...
Loading Plugin karma...
Trying Connect(('54.174.129.87', 6667))
Connection Open.
Starting Read/Write Loops
Starting Timers Loop
Loading Channels from DB
Traceback (most recent call last):
  File "/Users/josh/dev/jfhbrook/moodybot/env/lib/python2.7/site-packages/gevent/greenlet.py", line 534, in run
    result = self._run(*self.args, **self.kwargs)
  File "/Users/josh/dev/jfhbrook/moodybot/env/lib/python2.7/site-packages/pyaib/channels.py", line 55, in _autojoin
    self.db.commit()
  File "/Users/josh/dev/jfhbrook/moodybot/env/lib/python2.7/site-packages/pyaib/db.py", line 154, in commit
    self._meta['bucket'])
  File "/Users/josh/dev/jfhbrook/moodybot/env/lib/python2.7/site-packages/pyaib/dbd/sqlite.py", line 100, in updateObject
    self.setObject(obj, key, bucket)
  File "/Users/josh/dev/jfhbrook/moodybot/env/lib/python2.7/site-packages/pyaib/dbd/sqlite.py", line 96, in setObject
    (key, memoryview(compress(jsonify(obj)))))
InterfaceError: Error binding parameter 1 - probably unsupported type.
<Greenlet at 0x106b96050: <bound method Channels._autojoin of <pyaib.channels.Channels object at 0x106867110>>({u'reddit': <plugins.reddit.RedditTailer object at)> failed with InterfaceError

I've gotten about as far as noting that the tables are initialized to use blob types, and that rows are being saved with a string and a memoryview. Perhaps we need to typecast to a buffer on save ?

(that grequest fail is probably due to me calling a method I don't need to call in the ddg plugin, should be unrelated)

fried commented

i'll look at the db driver for sqlite and see why its not just storing json blobs. If you disable the db component in your config you should be ok you just won't have dynamic channel autojoin configuration.
i'll have to look at this on monday

Sent from my iPhone

On Sep 3, 2016, at 20:38, Joshua Holbrook <notifications@github.commailto:notifications@github.com> wrote:

I'm using this project for a community bot and just started upgrading to v2. This is in part because it looks like my bot doesn't create a sqlite db with v1 (maybe that functionality was shimmed back then?). While I didn't have my bot creating a sqlite db before, now I get this crazy error:

$ python ./moodybot.py
Config Module Loaded.
Loaded Config from moodybot.conf.
Loading Component triggers...
Triggers Loaded
Loading Component channels...
Channel Management Loaded
Loading Component plugins...
Loading Component db...
Sqlite DB Driver Loaded!
Loading Plugin ddg...
/Users/josh/dev/jfhbrook/moodybot/env/lib/python2.7/site-packages/grequests.py:21: RuntimeWarning: Patching more than once will result in the union of all True parameters being patched
curious_george.patch_all(thread=False, select=False)
Loading Plugin eliza...
Loading Plugin jokes...
Loading Plugin pug...
Loading Plugin reddit...
Loading Plugin source...
Loading Plugin karma...
Trying Connect(('54.174.129.87', 6667))
Connection Open.
Starting Read/Write Loops
Starting Timers Loop
Loading Channels from DB
Traceback (most recent call last):
File "/Users/josh/dev/jfhbrook/moodybot/env/lib/python2.7/site-packages/gevent/greenlet.py", line 534, in run
result = self._run(_self.args, *_self.kwargs)
File "/Users/josh/dev/jfhbrook/moodybot/env/lib/python2.7/site-packages/pyaib/channels.py", line 55, in _autojoin
self.db.commit()
File "/Users/josh/dev/jfhbrook/moodybot/env/lib/python2.7/site-packages/pyaib/db.py", line 154, in commit
self._meta['bucket'])
File "/Users/josh/dev/jfhbrook/moodybot/env/lib/python2.7/site-packages/pyaib/dbd/sqlite.py", line 100, in updateObject
self.setObject(obj, key, bucket)
File "/Users/josh/dev/jfhbrook/moodybot/env/lib/python2.7/site-packages/pyaib/dbd/sqlite.py", line 96, in setObject
(key, memoryview(compress(jsonify(obj)))))
InterfaceError: Error binding parameter 1 - probably unsupported type.
<Greenlet at 0x106b96050: <bound method Channels._autojoin of <pyaib.channels.Channels object at 0x106867110>>({u'reddit': <plugins.reddit.RedditTailer object at)> failed with InterfaceError

I've gotten about as far as noting that the tables are initialized to use blob typeshttps://github.com/facebook/pyaib/blob/master/pyaib/dbd/sqlite.py#L76-L77, and that rows are being saved with a string and a memoryviewhttps://github.com/facebook/pyaib/blob/master/pyaib/dbd/sqlite.py#L94-L96. Perhaps we need to typecast to a buffer on savehttps://urldefense.proofpoint.com/v2/url?u=https-3A__docs.python.org_2_library_functions.html-23buffer&d=DQMCaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=42DWR307dfreEAmMXUDsfQ&m=Y8uYHzkL1tPYx-Zcx9vCG2biN6T-AE_W7Mdj0P0e2Zs&s=r_l9MNqsv9hqyAVsaos_FHhtxclNopRJnDrJsBczK-4&e= ?

You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHubhttps://github.com//issues/16, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AAMPCfz_HRWmcZh_AhX4qqwjFvzZoIj2ks5qmj0VgaJpZM4J0cwP.

indeed---unfortunately I need the db component for a karma plugin I'm working on (and might try to upstream, if you're interested).

fried commented

you can set the db key in channel config to False and it will stop trying to use the db there.

Sent from my iPhone

On Sep 4, 2016, at 12:40, Joshua Holbrook <notifications@github.commailto:notifications@github.com> wrote:

indeed---unfortunately I need the db component for a karma plugin I'm working on (and might try to upstream, if you're interested).

You are receiving this because you commented.
Reply to this email directly, view it on GitHubhttps://github.com//issues/16#issuecomment-244624267, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AAMPCcdEMj4pyDOvvA5Z0pMqUh44WN_aks5qmx6YgaJpZM4J0cwP.

fried commented

I have a karma plugin internally that we should be able to open source now that it only uses the db component

Sent from my iPhone

On Sep 4, 2016, at 12:40, Joshua Holbrook <notifications@github.commailto:notifications@github.com> wrote:

indeed---unfortunately I need the db component for a karma plugin I'm working on (and might try to upstream, if you're interested).

You are receiving this because you commented.
Reply to this email directly, view it on GitHubhttps://github.com//issues/16#issuecomment-244624267, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AAMPCcdEMj4pyDOvvA5Z0pMqUh44WN_aks5qmx6YgaJpZM4J0cwP.

fried commented

Thanks for raising this issue, It should be resolved now. I'll update pypi today or tomorrow.

I also added the karma plugin we use internally at Facebook, enjoy.