zatosource / zato

ESB, SOA, REST, APIs and Cloud Integrations in Python
https://zato.io
GNU Affero General Public License v3.0
1.12k stars 240 forks source link

I can't upload a service code that contains sqlalchemy class, what should I do? #1032

Closed aixi88 closed 4 years ago

aixi88 commented 4 years ago

The following code changes Base to object that can be uploaded,why? thanks!

from sqlalchemy import Numeric, String, Column from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() from zato.server.service import Service

class so_dispatchlist(Base):

__tablename__ = 'so_dispatchlist'

ccode = Column(String(200), unique=True, nullable=False)
ccuscode = Column(String(200), nullable=False)
cinvcode = Column(String(1000), nullable=True)
fh_iquantity = Column(Numeric(), nullable=False)

class CustomerConsignmentService(Service): class SimpleIO: input_required = ('ccuscode') output_required = ('ccode', 'so_dispatchlist_list')

def handle(self):
    pass
dsuch commented 4 years ago

Hello @aixi88,

I have no idea what you mean, what you are trying to do, what works, what does not work and what you expect for the end result to be.

Your code cannot be read because it is not formatted at all.

I am closing this ticket - feel free reopen after rectifying these matters.

Regards.

aixi88 commented 4 years ago

@dsuch sorry ,My English is not good, so the expression is not very clear, the following code upload can not be found in the service, unless you change the class so_dispatchlist (Base) to class so_dispatchlist (object)

from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
from zato.server.service import Service

class so_dispatchlist(Base):

    __tablename__ = 'so_dispatchlist'

    ccode = Column(String(200), unique=True, nullable=False)
    ccuscode = Column(String(200), nullable=False)
    cinvcode = Column(String(1000), nullable=True)
    fh_iquantity = Column(Numeric(), nullable=False)

class CustomerConsignmentService(Service):
    class SimpleIO:
        input_required = ('ccuscode')
        output_required = ('ccode', 'so_dispatchlist_list')

    def handle(self):
        pass
dsuch commented 4 years ago

Ok, but I do not understand what does not work exactly, what do you mean by "cannot be found"?

This is an SQLAlchemy class, not a Zato one, and I do not know how they work like exactly.

aixi88 commented 4 years ago

@dsuch thanks! cannot be found on : http:// 8183/zato/service/?cluster=1 ,after upload services zato1

dsuch commented 4 years ago

Do you know that there is a file called server.log which contains various details, including exceptions or errors?

aixi88 commented 4 years ago

@dsuch thank you.I'll find it myself.

dsuch commented 4 years ago

I see - let me explain. A file called server.log is one of the log files that exist for each server. This one is the main one where you will likely find an explanation, a Python traceback, with details that prevent Zato from deploying your service.

You need to somehow SSH into your server and find the file. I am not really familiar with Docker so I do not know how to use SSH with Swarm.

aixi88 commented 4 years ago

@dsuch I found out why, because there was no primary_key,thank you!

class so_dispatchlist(Base):

    __tablename__ = 'so_dispatchlist'

    ccode = Column(String(200), primary_key=True)
    ccuscode = Column(String(200), nullable=False)
    cinvcode = Column(String(1000), nullable=True)
    fh_iquantity = Column(Numeric(), nullable=False)
dsuch commented 4 years ago

OK, this is good to hear.