Skip to content

Instantly share code, notes, and snippets.

Avatar
🍀

Dariusz Suchojad dsuch

🍀
View GitHub Profile
View sa_no_rollback.py
from sqlalchemy import create_engine
config = {
'username': 'zato1',
'password': 'zato1',
'database': 'zato1',
}
url = 'postgresql+pg8000://{username}:{password}@localhost/{database}'.format(**config)
engine = create_engine(url, echo=True)
View sa_with_rollback.py
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
config = {
'username': 'zato1',
'password': 'zato1',
'database': 'zato1',
}
View getfullsecdef.py
from zato.server.service import Service
class GetFullSecurityDefinitions(Service):
def handle(self):
for value in self.worker_store.request_dispatcher.url_data.basic_auth_config.values():
self.logger.info('\n%s', value.config)
View sql_auto_ping.py
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
# gevent
from gevent import sleep
# Zato
from zato.common.broker_message import SERVICE
from zato.common.util import new_cid
@dsuch
dsuch / client.py
Created May 22, 2015
Obtaining self.broker_client without self
View client.py
# stdlib
import gc
# Zato
from zato.common.broker_message import SERVICE
from zato.common.util import new_cid
from zato.server.base.parallel import ParallelServer
from zato.server.service import Integer, Service
@dsuch
dsuch / zato_pymqi.py
Created Apr 21, 2015
PyMQI directly under Zato
View zato_pymqi.py
from zato.server.service import Service
class MyService(Service):
def handle(self):
import pymqi
queue_manager = 'IDM'
@dsuch
dsuch / sqlserver.txt
Created Mar 23, 2015
SQL Server + Zato
View sqlserver.txt
I have solved the problem by modifying these lines in zato. I do not know if this has been the best method , but it has worked to give ZATO connectivity with SqlServer.
First of all , I installed and configured FreeTDS and unixODBC (http://blog.tryolabs.com/2012/06/25/connecting-sql-server-database-python-under-ubuntu/)
Then:
In /opt/zato/2.0.0/local/zato-common/src/zato/common/init.py,
add 'mssql+pyodbc': 'SELECT 1',
to var: ping_queries
In /opt/zato/2.0.0/zato-web-admin/src/zato/admin/zato_settings.py,
@dsuch
dsuch / orders.py
Last active Aug 29, 2015
How to use async callbacks
View orders.py
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
# Zato
from zato.server.service import Service
ORDER_CACHE_PREFIX = 'order.{}'
class AcceptOrder(Service):
@dsuch
dsuch / dicts1.py
Created Feb 4, 2015
Using KVDB get-key-list and get-value-list
View dicts1.py
from zato.server.service import Service
class Dicts(Service):
def handle(self):
service = 'zato.kvdb.data-dict.dictionary.get-key-list'
request = {'system':'System'}
response = self.invoke(service, request)
View getcust2.py
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
# stdlib
from random import choice
# Zato
from zato.server.service import Service