bots - MySQLdatabase

147 views
Skip to first unread message

IcedShadow

unread,
Sep 11, 2012, 4:31:01 AM9/11/12
to bots...@googlegroups.com
Hi,

I got a little problem.
I tried to write something from bots in my MySqLdatabase. For this purpose i modified the communicationscript from the example, but it doesn´t work.

Here is my communicationscript:

import MySQLdb as mdb
import sys

def connect(channeldict):
    return mdb.connect('localhost','root','','ibox_control')


def outcommunicate(channeldict, dbconnection,db_object):
    cursor = dbconnection.cursor()
    for article in db_object:
   
        cursor.execute("INSERT INTO ccode (ccodeid) VALUES   ('?')", article)
    connect.commit()
    cursor.close()
   
 
def disconnect(channeldict, dbconnection):
    dbconnection.close()


Any ideas what went wrong here?

greetings
IcedShadow

henk-jan ebbers

unread,
Sep 11, 2012, 5:59:15 AM9/11/12
to bots...@googlegroups.com
what is the error you get?

kind regards,
henk-jan

IcedShadow

unread,
Sep 11, 2012, 7:06:10 AM9/11/12
to bots...@googlegroups.com
when i look under "process errors" it shows nothing.
But in the command line it says:

1 files received/processed in run
1 files with errors
0 files send in run

kind regards,
IcedShadow

henk-jan ebbers

unread,
Sep 11, 2012, 7:11:41 AM9/11/12
to bots...@googlegroups.com
so...what is the file error.....

henk-jan

IcedShadow

unread,
Sep 11, 2012, 8:37:52 AM9/11/12
to bots...@googlegroups.com

where can i look for the file error? is there an error log?

henk-jan ebbers

unread,
Sep 11, 2012, 8:47:23 AM9/11/12
to bots...@googlegroups.com
???

it might be a good idea if you first have a decent look at the GUI? it is not a very complex one, so that would be easy ;-)
also, might be a good read some of the wiki.


kind regards,

Henk-Jan Ebbers

IcedShadow

unread,
Sep 11, 2012, 9:26:55 AM9/11/12
to bots...@googlegroups.com
Sorry, found it.

This is the error:

ScriptError: Script file "C:\Python27\lib\site-packages\bots\bots.usersys\communicationscripts\importarticlesxml_out": "TypeError: not all arguments converted during string formatting ".

kind regards,

Jan Thuß

henk-jan ebbers

unread,
Sep 11, 2012, 9:33:41 AM9/11/12
to bots...@googlegroups.com
in bots/config/bots.ini

turn debug on (debug=True), as mentioned on http://code.google.com/p/bots/wiki/Debug

it will give more information about the line in your script where the error occurs. that will be helpful here.


henk-jan

IcedShadow

unread,
Sep 11, 2012, 10:06:44 AM9/11/12
to bots...@googlegroups.com

thank´s a lot.
that really helps.

greetings
IcedShadow

henk-jan ebbers

unread,
Sep 11, 2012, 10:47:19 AM9/11/12
to bots...@googlegroups.com
my pleasure.

btw do you happen t obe Dutch or German?
(name sounds like you are)

henk-jan

IcedShadow

unread,
Sep 12, 2012, 5:16:42 AM9/12/12
to bots...@googlegroups.com

Your right, i´m German.
I need an bots for an research-project at university. Quite nice programm.

jan

henk-jan ebbers

unread,
Sep 12, 2012, 7:30:23 AM9/12/12
to bots...@googlegroups.com
hey Jan,

that sounds very interesting.
what kind of project is it?

kind regards,
henk-jan

IcedShadow

unread,
Sep 13, 2012, 7:50:25 AM9/13/12
to bots...@googlegroups.com
hey Henk-Jan,

 I try to build an JIT-delivery-process for car industry in a smaller scale for later research purposes.
Therefor i use Bots as an EDI interpreter.

btw can you tell me what Bots mean with:

File "C:\Python27\lib\site-packages\bots\communication.py", line 1683, in outcommunicate botslib.runscript(self.userscript,self.scriptname,'outcommunicate',channeldict=self.channeldict,dbconnection=self.dbconnection,db_object=db_object)
File "C:\Python27\lib\site-packages\bots\botslib.py", line 618, in runscript raise ScriptError(_(u'Script file "$filename": "$txt".'),filename=modulefile,txt=txt)
ScriptError: Script file "C:\Python27\lib\site-packages\bots\bots.usersys\communicationscripts\importarticlesxml_out": " File "C:\Python27\lib\site-packages\bots\botslib.py", line 615, in runscript return functiontorun(**argv)

Is there any function or attribute incorrect?

This is my actual script:


import MySQLdb as mdb
import sys

def connect(channeldict):
    return mdb.connect('localhost','root','','ibox_control')


def outcommunicate(channeldict, dbconnection,db_object):
    cursor = dbconnection.cursor()
    for article in db_object:

        cursor.execute(u'''INSERT INTO ccode (ccodeid_id, leftcode, rightcode)
                            VALUES("%(ccodeid)s, %(leftcode)s, %(rightcode)s")''',
                            article)
    connect.commit()
    cursor.close()
   
 
def disconnect(channeldict, dbconnection):
    dbconnection.close()

Any ideas?

kind regards,
jan

henk-jan ebbers

unread,
Sep 13, 2012, 8:13:33 AM9/13/12
to bots...@googlegroups.com, jan....@web.de
hi Jan,

two things:

1. this error is not as it should be!
    error should point to line where is goes wrong.
    I would like to try and replicate this at my place, to improve this.
    is it possible for you to make a plugin for me in order to replicate this over here?
    generating a plugin is easy: in menu->Systask->generate plugin
    either a zip-file is written to system (you'll get notified where) or GUI offers to downlaod it (newer bots version)
     also: SQL-definition of tabel would be great

2. workaround: add some statements in script, eg like this:

import MySQLdb as mdb
import sys
import traceback

def connect(channeldict):

    return mdb.connect('localhost','root','','ibox_control')


def outcommunicate(channeldict, dbconnection,db_object):

    try:
        cursor = dbconnection.cursor()
        for article in db_object:

            cursor.execute(u'''INSERT INTO ccode (ccodeid_id, leftcode, rightcode)
                                VALUES("%(ccodeid)s, %(leftcode)s, %(rightcode)s")''',
                                article)
        connect.commit()
        cursor.close()
    except:
        traceback.print_exc()

 
def disconnect(channeldict, dbconnection):
    dbconnection.close()

this will print a 'better' error to console of engien (or if you run engine via menu, in the web-server console)
(I have send this email also directly to your address, hoping the layout of code is better)

kind regards,
henk-jan

SrinivasP EDI Tech Lead

unread,
Nov 7, 2021, 4:30:09 AM11/7/21
to Bots Open Source EDI Translator

Hello There,

Can you please help me with this issue here. 
I am getting below error 
Traceback (most recent call last): File "C:\Python27\lib\site-packages\bots\communication.py", line 1703, in outcommunicate botslib.runscript(self.userscript,self.scriptname,'outcommunicate',channeldict=self.channeldict,dbconnection=self.dbconnection,db_object=db_object) File "C:\Python27\lib\site-packages\bots\botslib.py", line 492, in runscript raise ScriptError(_(u'Userscript "%(modulefile)s": "%(txt)s".'),{'modulefile':modulefile,'txt':txt}) ScriptError: Userscript "C:\Python27\lib\site-packages\bots\usersys\communicationscripts\testmysqldbconnection": "Traceback (most recent call last): File "C:\Python27\lib\site-packages\bots\botslib.py", line 489, in runscript return functiontorun(**argv) File "C:\Python27\lib\site-packages\bots\usersys\communicationscripts\testmysqldbconnection.py", line 17, in outcommunicate cur.execute("""INSERT INTO ccode (ccodeid,leftcode,rightcode) VALUES (%s, %s, $s)""", ( article ) ) File "C:\Python27\lib\site-packages\MySQLdb\cursors.py", line 159, in execute query = query % db.literal(args) TypeError: not all arguments converted during string formatting

I have attached both communication script and translation script.
Can you please advice me

Eppye Bots

unread,
Nov 7, 2021, 6:40:16 AM11/7/21
to 'Chuck Turco' via Bots Open Source EDI Translator
this is not bots-specific.
it is about the database connector.
look at docs for MySQLdb


kind regards, Henk-Jan Ebbers


--
You received this message because you are subscribed to the Google Groups "Bots Open Source EDI Translator" group.
To unsubscribe from this group and stop receiving emails from it, send an email to botsmail+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/botsmail/6ba7ff65-f1f3-4294-ae0c-317207ec4e3dn%40googlegroups.com.

Hans

unread,
Nov 8, 2021, 4:06:13 AM11/8/21
to Bots Open Source EDI Translator
i like to mail the error's of outputs to myself for debugging purpouses.

import bots.transform as transform
from pprint import saferepr as pp

for article in db_object:
try:
cursor.execute( """INSERT INTO ccode (ccodeid,leftcode,rightcode) VALUES (%s, %s, $s)""", ( article ) )
except (MySQLdb.Error,MySQLdb.Warning) as e:
transform.sendbotsemail('PartnerIDwithyourmailaddress','mailsubject',pp(e))

Op zondag 7 november 2021 om 12:40:16 UTC+1 schreef eppye:

SrinivasP EDI Tech Lead

unread,
Nov 10, 2021, 12:46:42 AM11/10/21
to Bots Open Source EDI Translator
Hello There ,

Thank You  for your support.
Now I am able to fix the MySql database configuration and data insertion issue. 

Thanks
Reply all
Reply to author
Forward
0 new messages