コード例 #1
0
def client(lang, file, user = '******', passwd = 'monetdb'):
    sys.stderr.write('#client\n')
    sys.stderr.flush()
    clt = process.client(lang, user = user, passwd = passwd,
                         stdin = open(file),
                         stdout = process.PIPE, stderr = process.PIPE)
    return clt.communicate()
コード例 #2
0
ファイル: Dependencies.SQL.py プロジェクト: MonetDB/MonetDB
def client(cmd, infile, user = '******', passwd = 'monetdb'):
    clt = process.client(cmd, user = user, passwd = passwd,
                         stdin = open(infile), stdout = process.PIPE,
                         stderr = process.PIPE)
    out, err = clt.communicate()
    sys.stdout.write(out)
    sys.stderr.write(err)
コード例 #3
0
ファイル: create.SQL.py プロジェクト: MonetDB/MonetDB
def client(lang, user = '******', passwd = 'monetdb', input = None):
    clt = process.client(lang, user = user, passwd = passwd,
                         stdin = process.PIPE,
                         stdout = process.PIPE,
                         stderr = process.PIPE)
    out, err = clt.communicate(input)
    sys.stdout.write(out)
    sys.stderr.write(err)
コード例 #4
0
def client(input):
    c = process.client('sql',
                         stdin = process.PIPE,
                         stdout = process.PIPE,
                         stderr = process.PIPE)
    out, err = c.communicate(input)
    sys.stdout.write(out)
    sys.stderr.write(err)
コード例 #5
0
ファイル: VOC.SQL.py プロジェクト: MonetDB/MonetDB
def client(file, user, passwd):
    sys.stdout.flush()
    sys.stderr.flush()
    c = process.client(lang = 'sql',
                       user = user, passwd = passwd,
                       args = [os.path.join(d, os.pardir, file)],
                       log = True)
    c.communicate()
コード例 #6
0
ファイル: connections.py プロジェクト: cswxu/monetdb-mcs
def client(x,s, c, file):
    sys.stdout.write('\nserver %d%d, client %d\n' % (x,s,c))
    sys.stderr.write('\nserver %d%d, client %d\n' % (x,s,c))
    sys.stderr.flush()
    sys.stderr.write('#client%d\n' % x)
    sys.stdout.flush()
    sys.stderr.flush()
    clt = process.client('sql', stdin = process.PIPE,
                         stdout = process.PIPE, stderr = process.PIPE)
    port = int(os.getenv('MAPIPORT', '50000'))
    client_load_file(clt, port, file)
    return clt.communicate()
コード例 #7
0
def main():
    sys.stderr.write('#client\n')
    sys.stderr.flush()
    clt = process.client('sql', user = '******', passwd = 'monetdb',
                         stdin = process.PIPE,
                         stdout = process.PIPE, stderr = process.PIPE)
    currenttime = time.strftime('%H:%M:%S', time.localtime(time.time()))
    #SQL command for checking the localtime
    sqlcommand = "select localtime() between (time '%s' - interval '20' second) and (time '%s' + interval '20' second);" % (currenttime, currenttime)
    out, err = clt.communicate(sqlcommand)
    sys.stdout.write(out)
    sys.stderr.write(err)
コード例 #8
0
def client(cmd, infile = None):
    if infile is not None:
        f = open(infile)
    else:
        f = None
    clt = process.client(cmd, stdin = f,
                         stdout = process.PIPE, stderr = process.PIPE,
                         log = True)
    if f is not None:
        f.close()
    out, err = clt.communicate()
    sys.stdout.write(out)
    sys.stderr.write(err)
コード例 #9
0
def main():
    if time.daylight and time.gmtime(time.time()).tm_isdst:
        zone = time.altzone
    else:
        zone = time.timezone
    sys.stderr.write('#client\n')
    sys.stderr.flush()
    clt = process.client('sql', user = '******', passwd = 'monetdb',
                         stdin = process.PIPE,
                         stdout = process.PIPE, stderr = process.PIPE)
    currenttime = time.strftime('%H:%M:%S', time.localtime(time.time()))
    #SQL command for checking the localtime
    sqlcommand = "select localtime() between (time '%s' - interval '20' second) and (time '%s' + interval '20' second);" % (currenttime, currenttime)
    out, err = clt.communicate(sqlcommand)
    sys.stdout.write(out)
    sys.stderr.write(err)
    clt = process.client('sql', user = '******', passwd = 'monetdb',
                         stdin = process.PIPE,
                         stdout = process.PIPE, stderr = process.PIPE)
    out, err = clt.communicate('select localtime();')
    sys.stdout.write('#Python says: %s; current time zone %d\n' % (currenttime, zone))
    for line in out.split('\n'):
        if line:
            sys.stdout.write('#MonetDB says: %s\n' % line)
コード例 #10
0
ファイル: copyinto.SQL.py プロジェクト: f7753/monetdb
import os, sys
try:
    from MonetDBtesting import process
except ImportError:
    import process

TSTSRCBASE = os.environ['TSTSRCBASE']
SRCDIR = os.path.join(TSTSRCBASE, "sql", "benchmarks", "tpch")
DATADIR = os.path.join(SRCDIR,"SF-0.01") + os.sep.replace('\\', r'\\')

c = process.client('sql', stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE)
c.stdin.write("CREATE TABLE REGION ( R_REGIONKEY INTEGER NOT NULL, R_NAME CHAR(25) NOT NULL, R_COMMENT VARCHAR(152));")
c.stdin.write("COPY 5 RECORDS INTO region from '%s/region.tbl' USING DELIMITERS '|', '|\n';" % DATADIR)
c.stdin.write("select count(*) from region;");
c.stdin.write("CREATE USER copyuser WITH PASSWORD 'copyuser' name 'copyuser' schema sys;")
c.stdin.write("GRANT INSERT, SELECT on region to copyuser;")
out, err = c.communicate()
sys.stdout.write(out)
sys.stderr.write(err)

c = process.client('sql', user = '******', passwd = 'copyuser', stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE)
c.stdin.write("COPY 5 RECORDS INTO region from '%s/region.tbl' USING DELIMITERS '|', '|\n';" % DATADIR)
c.stdin.write("select count(*) from region;")
out, err = c.communicate()
sys.stdout.write(out)
sys.stderr.write(err)

c = process.client('sql', stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE)
c.stdin.write("GRANT COPY FROM, COPY INTO to copyuser;")
out, err = c.communicate()
sys.stdout.write(out)
コード例 #11
0
###
# Use functions that contain SELECT. INSERT, UPDATE, DELETE
# on a table for which the USER has GRANTs (possible).
###

import os, sys
try:
    from MonetDBtesting import process
except ImportError:
    import process

with process.client('sql',
                    user='******',
                    passwd='p1',
                    stdin=open(
                        os.path.join(os.getenv('RELSRCDIR'), os.pardir,
                                     'test_privs2.sql')),
                    stdout=process.PIPE,
                    stderr=process.PIPE) as clt:
    out, err = clt.communicate()
    sys.stdout.write(out)
    sys.stderr.write(err)
コード例 #12
0
tstdb = os.getenv('TSTDB')

if not tstdb or not dbfarm:
    print('No TSTDB or GDK_DBFARM in environment')
    sys.exit(1)

dbname = tstdb

s = process.server(dbname=dbname,
                   stdin=process.PIPE,
                   stdout=process.PIPE,
                   stderr=process.PIPE)

c = process.client('sql',
                   server=s,
                   stdin=process.PIPE,
                   stdout=process.PIPE,
                   stderr=process.PIPE)

cout, cerr = c.communicate('''\
update tmp set i = 3 where i = 1;
update tmp set s = 'blah';
select * from tmp;
''')

sout, serr = s.communicate()

sys.stdout.write(sout)
sys.stdout.write(cout)
sys.stderr.write(serr)
sys.stderr.write(cerr)
コード例 #13
0
import os, sys
try:
    from MonetDBtesting import process
except ImportError:
    import process

TSTSRCBASE = os.environ['TSTSRCBASE']
TSTDIR = os.environ['TSTDIR']
SRCDIR = os.path.join(TSTSRCBASE, TSTDIR)
DATADIR = (os.path.join(SRCDIR, "SF-0.01") + os.sep).replace('\\', r'\\')

with process.client('sql',
                    stdin=process.PIPE,
                    stdout=process.PIPE,
                    stderr=process.PIPE) as c:
    for ln in open(os.path.join(SRCDIR, "load-sf-0.01.sql")):
        c.stdin.write(ln.replace('PWD/', DATADIR))
    out, err = c.communicate()
    sys.stdout.write(out)
    sys.stderr.write(err)

with process.client('sql',
                    stdin=open(
                        os.path.join(os.environ['TSTSRCDIR'], "check1.sql")),
                    stdout=process.PIPE,
                    stderr=process.PIPE) as c:
    out, err = c.communicate()
    sys.stdout.write(out)
    sys.stderr.write(err)
コード例 #14
0
ファイル: test_privs2_p1.SQL.py プロジェクト: MonetDB/MonetDB
###
# Use functions that contain SELECT. INSERT, UPDATE, DELETE
# on a table for which the USER has GRANTs (possible).
###

import os, sys
try:
    from MonetDBtesting import process
except ImportError:
    import process

clt = process.client('sql', user = '******', passwd = 'p1',
                     stdin = open(os.path.join(os.getenv('RELSRCDIR'), os.pardir, 'test_privs2.sql')),
                     stdout = process.PIPE, stderr = process.PIPE)
out, err = clt.communicate()
sys.stdout.write(out)
sys.stderr.write(err)
コード例 #15
0
ファイル: ssbm.SQL.py プロジェクト: sekcheong/monetdb
    c.execute(atable)
    rtable = 'create remote table ' +  repltable + workerrec['tpf'] + ' ' + replicatedtabledef + ' on \'' + workerrec['mapi'] + '\''
    atable = 'alter table ' + repltable + ' add table ' + repltable + workerrec['tpf'];
    c.execute(rtable)
    c.execute(atable)

# sanity check
c.execute("select count(*) from lineorder")
print str(c.fetchall()[0][0]) + ' rows in mergetable'

# run queries, use mclient so output is comparable
queries = glob.glob(os.path.join(ssbmpath, '[0-1][0-9].sql'))
queries.sort()
for q in queries:
    print '# Running Q' +os.path.basename(q).replace('.sql','')
    mc = process.client('sql', stdin=open(q), dbname='master', host='localhost', port=masterport, stdout=process.PIPE, stderr=process.PIPE, log=1)
    out, err = mc.communicate()
    sys.stdout.write(out)
    sys.stderr.write(err)
    # old way
    # c.execute(codecs.open(q, 'r', encoding='utf8').read())
    # print c.fetchall()


for workerrec in workers:
    workerrec['proc'].communicate()

masterproc.communicate()

shutil.rmtree(tmpdir)
コード例 #16
0
ファイル: dump.SQL.py プロジェクト: Crixalis2013/MonetDB-1
try:
    from MonetDBtesting import process
except ImportError:
    import process

with process.client('sqldump', stdout=process.PIPE, stderr=process.PIPE) as c:
    out, err = c.communicate()

for line in out.splitlines():
    if line.startswith('--') or not line:
        continue
    if line != 'START TRANSACTION;' and line != 'COMMIT;':
        # unexpected output, dump it all
        print(out)
        break
コード例 #17
0
dbname = tstdb + '-bug2875'

# clean up before we start
if os.path.exists(os.path.join(dbfarm, dbname)):
    import shutil
    shutil.rmtree(os.path.join(dbfarm, dbname))

s = process.server(stdin=process.PIPE,
                   stdout=process.PIPE,
                   stderr=process.PIPE,
                   dbname=dbname)
out, err = s.communicate()
sys.stdout.write(out)
sys.stderr.write(err)
s = process.server(stdin=process.PIPE,
                   stdout=process.PIPE,
                   stderr=process.PIPE,
                   dbname=dbname)
c = process.client(lang='sqldump',
                   stdin=process.PIPE,
                   stdout=process.PIPE,
                   stderr=process.PIPE,
                   dbname=dbname)
out, err = c.communicate()
sys.stdout.write(out)
sys.stderr.write(err)
out, err = s.communicate()
sys.stdout.write(out)
sys.stderr.write(err)
コード例 #18
0
import os, sys, re
try:
    from MonetDBtesting import process
except ImportError:
    import process

TSTSRCDIR = os.environ['TSTSRCDIR']

with process.client('sql',
                    stdin=process.PIPE,
                    stdout=process.PIPE,
                    stderr=process.PIPE) as c:
    c.stdin.write("set optimizer = 'sequential_pipe';\n")
    c.stdin.write('explain\n')
    for ln in open(os.path.join(TSTSRCDIR, "%s.sql" % os.environ['TST'][0:2])):
        c.stdin.write(ln)
    out, err = c.communicate()
    sys.stdout.write(out)
    sys.stderr.write(err)
コード例 #19
0
with tempfile.TemporaryDirectory() as farm_dir:
    os.mkdir(os.path.join(farm_dir, 'db1'))
    with process.server(mapiport=myport,
                        dbname='db1',
                        dbfarm=os.path.join(farm_dir, 'db1'),
                        stdin=process.PIPE,
                        stdout=process.PIPE,
                        stderr=process.PIPE) as s:
        out, err = s.communicate()
        sys.stdout.write(out)
        sys.stderr.write(err)
    with process.server(mapiport=myport,
                        dbname='db1',
                        dbfarm=os.path.join(farm_dir, 'db1'),
                        stdin=process.PIPE,
                        stdout=process.PIPE,
                        stderr=process.PIPE) as s:
        with process.client(lang='sqldump',
                            port=myport,
                            dbname='db1',
                            stdin=process.PIPE,
                            stdout=process.PIPE,
                            stderr=process.PIPE,
                            server=s) as c:
            out, err = c.communicate()
            sys.stdout.write(out)
            sys.stderr.write(err)
        out, err = s.communicate()
        sys.stdout.write(out)
        sys.stderr.write(err)
コード例 #20
0
ファイル: wlr70.py プロジェクト: gsvic/MonetDB-1
def freeport():
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.bind(('', 0))
    port = sock.getsockname()[1]
    sock.close()
    return port

cloneport = freeport()

dbname = tstdb
dbnameclone = tstdb + 'clone'

#master = process.server(dbname = dbname, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE)
with process.server(dbname=dbnameclone, mapiport=cloneport, stdin=process.PIPE, stdout=process.PIPE, stderr=process.PIPE) as slave, \
     process.client('sql', server = slave, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE) as c:

    # make sure we are a little behind the wlc70.py
    time.sleep(3);
    # the previous test did not prepare the log files
    cout, cerr = c.communicate('''\
call wlr.master('%s');
#select now();
call wlr.replicate(now());
select * from tmp70;
''' % dbname)

    sout, serr = slave.communicate()
    #mout, merr = master.communicate()

    #sys.stdout.write(mout)
コード例 #21
0
import sys
try:
    from MonetDBtesting import process
except ImportError:
    import process

c = process.client('sql',
                   user='******',
                   passwd='invalid',
                   stdout=process.PIPE,
                   stderr=process.PIPE)
out, err = c.communicate()
sys.stdout.write(out)
sys.stderr.write(err)
コード例 #22
0
dbname = tstdb + '-bug2875'

# clean up before we start
if os.path.exists(os.path.join(dbfarm, dbname)):
    import shutil
    shutil.rmtree(os.path.join(dbfarm, dbname))

s = process.server(stdin = process.PIPE,
                   stdout = process.PIPE,
                   stderr = process.PIPE,
                   dbname = dbname)
out, err = s.communicate()
sys.stdout.write(out)
sys.stderr.write(err)
s = process.server(stdin = process.PIPE,
                   stdout = process.PIPE,
                   stderr = process.PIPE,
                   dbname = dbname)
c = process.client(lang = 'sqldump',
                   stdin = process.PIPE,
                   stdout = process.PIPE,
                   stderr = process.PIPE,
                   server = s)
out, err = c.communicate()
sys.stdout.write(out)
sys.stderr.write(err)
out, err = s.communicate()
sys.stdout.write(out)
sys.stderr.write(err)
コード例 #23
0
def client(args):
    clt = process.client('sql', args = args, log = True,
                         stdout = process.PIPE, stderr = process.PIPE)
    out, err = clt.communicate()
    sys.stdout.write(out)
    sys.stderr.write(err)
コード例 #24
0
from MonetDBtesting.sqltest import SQLTestCase
try:
    from MonetDBtesting import process
except ImportError:
    import process


with SQLTestCase() as tc:
    tc.connect(username="******", password="******")
    tc.execute("create table nonutf8 (s string);").assertSucceeded()

# input is a byte string because it contains broken utf-8
INPUT1 = b"""
insert into nonutf8 values ('\x7A\x77\x61\x61\x72\x20\x6C\x61\x6E\x67\x65\x20\x67\x6F\x6C\x66\x20\x70\x69\x65\x6B\x20\x2D\x64\x61\x6C\x20\xB1\x31\x30\x63\x6D\x20\x76\x61\x6B\x35');
"""
with process.client('sql', text=False, stdin=process.PIPE, stdout=process.PIPE, stderr=process.PIPE) as c:
    out, err = c.communicate(INPUT1)
    retcode = c.returncode

    if retcode == 0:
        sys.stderr.write("Expected nonzero return code")
    if not err or b'invalid start of UTF-8 sequence' not in err:
        sys.stderr.write("Expected stderr to contain 'invalid start of UTF-8 sequence'")

# input is a byte string because it contains broken utf-8
INPUT2 = b"""
copy 2 records into nonutf8 from stdin;
\x7A\x77\x61\x61\x72\x20\x6C\x61\x6E\x67\x65\x20\x67\x6F\x6C\x66\x20\x70\x69\x65\x6B\x20\x2D\x64\x61\x6C\x20\xB1\x31\x30\x63\x6D\x20\x76\x61\x6B\x35\x0A\xB1\x31\x37\x20\x25

"""
with process.client('sql', text=False, stdin=process.PIPE, stdout=process.PIPE, stderr=process.PIPE) as c:
コード例 #25
0
import os, sys
try:
    from MonetDBtesting import process
except ImportError:
    import process

with process.client(
        'sql',
        args=
    [
        '-s',
        'CREATE USER "testuser" WITH PASSWORD \'password\' NAME \'Test User\' SCHEMA "sys";'
    ],
        stdout=process.PIPE,
        stderr=process.PIPE) as c:
    out, err = c.communicate()
    if out:
        sys.stdout.write(out)
    if err:
        sys.stderr.write(err)

with process.client(
        'sql',
        args=['-s', 'CREATE GLOBAL TEMPORARY TABLE TempTable (i int);'],
        user='******',
        passwd='password',
        stdout=process.PIPE,
        stderr=process.PIPE) as c:
    out, err = c.communicate()
    if out:
        sys.stdout.write(out)
コード例 #26
0
import os, sys, tempfile

try:
    from MonetDBtesting import process
except ImportError:
    import process

(fd, tmpf) = tempfile.mkstemp(suffix='.lz4', text=True)
os.close(fd)
os.unlink(tmpf)

s = process.server(args=[], stdin=process.PIPE, stdout=process.PIPE, stderr=process.PIPE)

data = open(os.path.join(os.getenv('TSTSRCDIR'), 'lz4-dump.sql')).read()

c = process.client('sql', stdin=process.PIPE,
                   stdout=process.PIPE, stderr=process.PIPE, log=True)
out, err = c.communicate(data.replace('/tmp/testing-dump.lz4', tmpf))
sys.stdout.write(out)
sys.stderr.write(err)

out, err = s.communicate()
sys.stdout.write(out)
sys.stderr.write(err)

try:
    os.unlink(tmpf)
except:
    pass
コード例 #27
0
ファイル: reload.SQL.py プロジェクト: snaga/monetdb
import os, sys
try:
    from MonetDBtesting import process
except ImportError:
    import process

clt = process.client('sql', user = '******', passwd = 'monetdb',
                     stdin = open(os.path.join(os.environ['TSTTRGDIR'],
                                               'dumpoutput.sql'), 'r'),
                     stdout = process.PIPE, stderr = process.PIPE)
out, err = clt.communicate()
sys.stdout.write(out)
sys.stderr.write(err)
コード例 #28
0
ファイル: check.SQL.py プロジェクト: siddharthrai/MonetDB
import os, sys, re
try:
    from MonetDBtesting import process
except ImportError:
    import process

clt = process.client('sql',
                     format='csv',
                     echo=False,
                     stdin=process.PIPE,
                     stdout=process.PIPE,
                     stderr=process.PIPE)

for c in 'ntvsf':
    clt.stdin.write("select '\\\\d%s';\n" % c)

for c in 'ntvsf':
    clt.stdin.write("select '\\\\dS%s';\n" % c)

clt.stdin.write("select '\\\\dn ' || name from sys.schemas order by name;\n")

clt.stdin.write(
    "select '\\\\dSt ' || s.name || '.' || t.name from sys._tables t, sys.schemas s where t.schema_id = s.id and t.query is null order by s.name, t.name;\n"
)

clt.stdin.write(
    "select '\\\\dSv ' || s.name || '.' || t.name from sys._tables t, sys.schemas s where t.schema_id = s.id and t.query is not null order by s.name, t.name;\n"
)

clt.stdin.write(
    "select distinct '\\\\dSf ' || s.name || '.\"' || f.name || '\"' from sys.functions f, sys.schemas s where f.language between 1 and 2 and f.schema_id = s.id and s.name = 'sys' order by s.name, f.name;\n"
コード例 #29
0
import os, sys
try:
    from MonetDBtesting import process
except ImportError:
    import process

n = 100000000
clt = process.client('sql',
                     stdin = process.PIPE,
                     stdout = process.PIPE,
                     stderr = process.PIPE,
                     interactive = False,
                     echo = False)
clt.stdin.write('start transaction;\n')
clt.stdin.write('create table n8 (a numeric(14,2));\n')
clt.stdin.write('copy %d records into n8 from stdin;\n' % n)
s = '1.21\n' * 1000
for i in xrange(n / 1000):
    clt.stdin.write(s)
clt.stdin.write("select 'avg(sqrt(n8)) == 1.1', avg(sqrt(a)) from n8;\n")
clt.stdin.write('rollback;\n')
out, err = clt.communicate()
sys.stdout.write(out)
sys.stderr.write(err)
コード例 #30
0
ファイル: unknown_user.SQL.py プロジェクト: snaga/monetdb
import sys
try:
    from MonetDBtesting import process
except ImportError:
    import process

clt = process.client('sql',
                     user = '******',
                     passwd = 'this_password_does_not_exist',
                     stdout = process.PIPE, stderr = process.PIPE)
out, err = clt.communicate()
sys.stdout.write(out)
sys.stderr.write(err)
コード例 #31
0
import os, sys
try:
    from MonetDBtesting import process
except ImportError:
    import process

c = process.client('sql',
                   args=[
                       os.path.join(os.getenv('TSTSRCBASE'),
                                    os.getenv('TSTDIR'), 'null-byte-hang.sql')
                   ],
                   stdout=process.PIPE,
                   stderr=process.PIPE)
out, err = c.communicate()
sys.stdout.write(out)
sys.stderr.write(err)
コード例 #32
0
import os, sys, shutil
try:
    from MonetDBtesting import process
except ImportError:
    import process

src = os.environ['RELSRCDIR']
dst = os.environ['TSTTRGDIR']

with process.client('sql',
                    stdin=process.PIPE,
                    stdout=process.PIPE,
                    stderr=process.PIPE,
                    interactive=False,
                    echo=False) as clt:
    shutil.copyfile(os.path.join(src,'n_nationkey.sorted'), os.path.join(dst,'n_nationkey.sorted'))
    shutil.copyfile(os.path.join(src,'n_regionkey.sorted'), os.path.join(dst,'n_regionkey.sorted'))

    clt.stdin.write('start transaction;');
    clt.stdin.write('create table bug (n_nationkey INTEGER,n_regionkey INTEGER);\n')
    clt.stdin.write('copy binary into bug from E\'{}\', E\'{}\';\n'.format(
        os.path.join(dst, 'n_nationkey.sorted').replace('\\', '\\\\'),
        os.path.join(dst, 'n_regionkey.sorted').replace('\\', '\\\\')))

    out, err = clt.communicate()
    # normalize output
    sys.stdout.write(out.replace(os.environ['TSTTRGBASE'].replace('\\', '\\\\'),'${TSTTRGBASE}').replace('\\\\','/'))
    sys.stderr.write(err.replace(os.environ['TSTTRGBASE'].replace('\\', '\\\\'),'${TSTTRGBASE}').replace('\\\\','/'))
コード例 #33
0
if not os.path.exists(archive):
    print('file "{}" not found'.format(archive), file=sys.stderr)
    sys.exit(1)

# unpackage database
with zipfile.ZipFile(archive) as z:
    z.extractall(path=db)

# start server and dump database
with process.server(mapiport='0',
                    stdin=process.PIPE,
                    stdout=process.PIPE,
                    stderr=process.PIPE) as srv:
    with process.client(lang='sqldump',
                        stdin=process.PIPE,
                        stdout=process.PIPE,
                        stderr=process.PIPE,
                        server=srv) as clt:
        cltout, clterr = clt.communicate()
    srvout, srverr = srv.communicate()

srvout = [
    line for line in srvout.splitlines(keepends=True)
    if not line.startswith('#')
]
cltout = [
    line for line in cltout.splitlines(keepends=False)
    if not line.startswith('--')
]

# check server output (upgrade commands) and check dump (empty)
コード例 #34
0
import os, sys
try:
    from MonetDBtesting import process
except ImportError:
    import process

d = os.getenv('TSTSRCDIR')

sys.stdout.write('Run test\n')
c = process.client('sql',
                   args=[
                       os.path.join(
                           d, os.pardir,
                           'set_history_and_drop_table.SF-2607045.sql')
                   ],
                   stdout=process.PIPE,
                   stderr=process.PIPE)
out, err = c.communicate()
sys.stdout.write(out)
sys.stderr.write(err)

sys.stdout.write('Drop history\n')
c = process.client('sql',
                   args=[os.path.join(d, os.pardir, 'drop_history.sql')],
                   stdout=process.PIPE,
                   stderr=process.PIPE)
out, err = c.communicate()
sys.stdout.write(out)
sys.stderr.write(err)
コード例 #35
0
import os, sys
try:
    from MonetDBtesting import process
except ImportError:
    import process

with process.client('sql',
                    stdin=open(
                        os.path.join(os.getenv('TSTSRCDIR'), os.path.pardir,
                                     'dumping_tables.SF-2776908.sql')),
                    stdout=process.PIPE,
                    stderr=process.PIPE) as c:
    out, err = c.communicate()
    sys.stdout.write(out)
    sys.stderr.write(err)
コード例 #36
0
ファイル: testdb-dump.SQL.py プロジェクト: snaga/monetdb
import sys
try:
    from MonetDBtesting import process
except ImportError:
    import process

sys.stdout.flush()              # just to be sure
p = process.client('sqldump', stderr = process.PIPE)
out, err = p.communicate()
sys.stderr.write(err)
コード例 #37
0
 def run(self):
     for i in range(NITER):
         c = process.client('sql', stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE)
         out, err = c.communicate(self.query)
コード例 #38
0
import os, socket, sys, tempfile
try:
    from MonetDBtesting import process
except ImportError:
    import process

def freeport():
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.bind(('', 0))
    port = sock.getsockname()[1]
    sock.close()
    return port

myport = freeport()

with tempfile.TemporaryDirectory() as farm_dir:
    os.mkdir(os.path.join(farm_dir, 'db1'))
    with process.server(mapiport=myport, dbname='db1',
                        dbfarm=os.path.join(farm_dir, 'db1'),
                        stdin=process.PIPE,
                         stdout=process.PIPE, stderr=process.PIPE) as srv:
        with process.client('sql', port=myport, dbname='db1',
                            stdin=process.PIPE, stdout=process.PIPE,
                            stderr=process.PIPE) as c:
            out, err = c.communicate('call sys.shutdown(10);')
            sys.stdout.write(out)
            sys.stderr.write(err)
        out, err = srv.communicate()
        sys.stdout.write(out)
        sys.stderr.write(err)
コード例 #39
0
except ImportError:
    import process

dbfarm = os.getenv("GDK_DBFARM")
tstdb = os.getenv("TSTDB")

if not tstdb or not dbfarm:
    print "No TSTDB or GDK_DBFARM in environment"
    sys.exit(1)

dbname = tstdb + "-bug2875"

# clean up before we start
if os.path.exists(os.path.join(dbfarm, dbname)):
    import shutil

    shutil.rmtree(os.path.join(dbfarm, dbname))

s = process.server(stdin=process.PIPE, stdout=process.PIPE, stderr=process.PIPE, dbname=dbname)
out, err = s.communicate()
sys.stdout.write(out)
sys.stderr.write(err)
s = process.server(stdin=process.PIPE, stdout=process.PIPE, stderr=process.PIPE, dbname=dbname)
c = process.client(lang="sqldump", stdin=process.PIPE, stdout=process.PIPE, stderr=process.PIPE, dbname=dbname)
out, err = c.communicate()
sys.stdout.write(out)
sys.stderr.write(err)
out, err = s.communicate()
sys.stdout.write(out)
sys.stderr.write(err)
コード例 #40
0
    print('file "{}" not found'.format(archive), file=sys.stderr)
    sys.exit(1)

# unpackage database
with zipfile.ZipFile(archive) as z:
    z.extractall(path=db)

# start server and dump database
with process.server(mapiport='0',
                    stdin=process.PIPE,
                    stdout=process.PIPE,
                    stderr=process.PIPE) as srv:
    with process.client(lang='sql',
                        user='******',
                        passwd='testpassword',
                        stdin=process.PIPE,
                        stdout=process.PIPE,
                        stderr=process.PIPE,
                        server=srv) as clt:
        cltout, clterr = clt.communicate(
            'select count(*) from testschema.smallstring;\n')
    srvout, srverr = srv.communicate()

srvout = [
    line for line in srvout.splitlines(keepends=True)
    if not line.startswith('#')
]

# check server output (upgrade commands) and check dump (empty)
if len(sys.argv) == 2 and sys.argv[1] == 'upgrade':
    bits = os.getenv('TST_BITS')
コード例 #41
0
ファイル: reload-again.SQL.py プロジェクト: MonetDB/MonetDB
import os, sys
try:
    from MonetDBtesting import process
except ImportError:
    import process

clt = process.client('sql', user = '******', passwd = 'monetdb',
                     stdin = open(os.path.join(os.environ['TSTTRGDIR'],
                                               'dumpoutput2.sql'), 'r'),
                     stdout = process.PIPE, stderr = process.PIPE)
out, err = clt.communicate()
sys.stdout.write(out)
sys.stderr.write(err)
コード例 #42
0
import os, sys
try:
    from MonetDBtesting import process
except ImportError:
    import process

c = process.client('sql',
                   stdin = open(os.path.join(os.getenv('TSTSRCDIR'),
                                             os.path.pardir,
                                             'dumping_tables.SF-2776908.sql')),
                   stdout = process.PIPE, stderr = process.PIPE,
                   log = True)
out, err = c.communicate()
sys.stdout.write(out)
sys.stderr.write(err)
コード例 #43
0
ファイル: like_tests.SQL.py プロジェクト: MonetDB/MonetDB
import os, sys
try:
    from MonetDBtesting import process
except ImportError:
    import process

c = process.client('sql',
                   args = [os.path.join(os.getenv('TSTSRCBASE'),
                                        os.getenv('TSTDIR'),
                                        'like_tests.sql')],
                   stdout = process.PIPE, stderr = process.PIPE)
out, err = c.communicate()
sys.stdout.write(out)
sys.stderr.write(err)
コード例 #44
0
ファイル: utf8test.SQL.py プロジェクト: MonetDB/MonetDB
def client(args, universal_newlines = True):
    clt = process.client('sql', args = args,
                         stdout = process.PIPE, stderr = process.PIPE,
                         universal_newlines = universal_newlines)
    return clt.communicate()
コード例 #45
0
ファイル: Skyserver.SQL.py プロジェクト: Clay-Birkett/monetdb
def main():
    user = '******'
    passwd = 'skyserver'
    dir = os.getenv('TSTSRCDIR')
    sys.stdout.write('Create User\n')
    sys.stderr.write('Create User\n')
    clt = process.client('sql', args = [os.path.join(dir, os.pardir,'create_user.sql')], stdout = process.PIPE, stderr = process.PIPE)
    out,err = clt.communicate()
    sys.stdout.write(out)
    sys.stderr.write(err)
    sys.stdout.write('tables\n')
    sys.stderr.write('tables\n')
    clt1 = process.client('sql', user = user, passwd = passwd, args = [os.path.join(dir, os.pardir,os.pardir,os.pardir,'scripts','10_math.sql')], stdout = process.PIPE, stderr = process.PIPE)
    out,err = clt1.communicate()
    sys.stdout.write(out)
    sys.stderr.write(err)
    clt1 = process.client('sql', user = user, passwd = passwd, args = [os.path.join(dir, os.pardir,os.pardir,os.pardir,'scripts','23_skyserver.sql')], stdout = process.PIPE, stderr = process.PIPE)
    out,err = clt1.communicate()
    sys.stdout.write(out)
    sys.stderr.write(err)
    clt1 = process.client('sql', user = user, passwd = passwd, args = [os.path.join(dir, os.pardir,'Skyserver_tables.sql')], stdout = process.PIPE, stderr = process.PIPE)
    out,err = clt1.communicate()
    sys.stdout.write(out)
    sys.stderr.write(err)
    clt1 = process.client('sql', user = '******', passwd = 'monetdb', stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE)
    sql = open(os.path.join(dir, os.pardir, 'Skyserver_import.sql')).read().replace('DATA',os.path.join(dir,os.pardir,'microsky').replace('\\','\\\\'))
    out,err = clt1.communicate(sql)
    sys.stdout.write(out)
    sys.stderr.write(err)
    clt1 = process.client('sql', user = user, passwd = passwd, args = [os.path.join(dir, os.pardir,'Skyserver_constraints.sql')], stdout = process.PIPE, stderr = process.PIPE)
    out,err = clt1.communicate()
    sys.stdout.write(out)
    sys.stderr.write(err)
    sys.stdout.write('views\n')
    sys.stderr.write('views\n')
    clt1 = process.client('sql', user = user, passwd = passwd, args = [os.path.join(dir, os.pardir,'Skyserver_views.sql')], stdout = process.PIPE, stderr = process.PIPE)
    out,err = clt1.communicate()
    sys.stdout.write(out)
    sys.stderr.write(err)
    sys.stdout.write('functions\n')
    sys.stderr.write('functions\n')
    clt1 = process.client('sql', user = user, passwd = passwd, args = [os.path.join(dir, os.pardir,'Skyserver_functions.sql')], stdout = process.PIPE, stderr = process.PIPE)
    out,err = clt1.communicate()
    sys.stdout.write(out)
    sys.stderr.write(err)
    sys.stdout.write('Cleanup\n')
    sys.stderr.write('Cleanup\n')
    clt1 = process.client('sql', user = user, passwd = passwd, args = [os.path.join(dir, os.pardir,'Skyserver_dropFunctions.sql')], stdout = process.PIPE, stderr = process.PIPE)
    out,err = clt1.communicate()
    sys.stdout.write(out)
    sys.stderr.write(err)
    clt1 = process.client('sql', user = user, passwd = passwd, args = [os.path.join(dir, os.pardir,'Skyserver_dropMs_functions.sql')], stdout = process.PIPE, stderr = process.PIPE)
    out,err = clt1.communicate()
    sys.stdout.write(out)
    sys.stderr.write(err)
    clt1 = process.client('sql', user = user, passwd = passwd, args = [os.path.join(dir, os.pardir,'Skyserver_dropMath.sql')], stdout = process.PIPE, stderr = process.PIPE)
    out,err = clt1.communicate()
    sys.stdout.write(out)
    sys.stderr.write(err)
    clt1 = process.client('sql', user = user, passwd = passwd, args = [os.path.join(dir, os.pardir,'Skyserver_dropViews.sql')], stdout = process.PIPE, stderr = process.PIPE)
    out,err = clt1.communicate()
    sys.stdout.write(out)
    sys.stderr.write(err)
    clt1 = process.client('sql', user = user, passwd = passwd, args = [os.path.join(dir, os.pardir,'Skyserver_dropConstraints.sql')], stdout = process.PIPE, stderr = process.PIPE)
    out,err = clt1.communicate()
    sys.stdout.write(out)
    sys.stderr.write(err)
    clt1 = process.client('sql', user = user, passwd = passwd, args = [os.path.join(dir, os.pardir,'Skyserver_dropTables.sql')], stdout = process.PIPE, stderr = process.PIPE)
    out,err = clt1.communicate()
    sys.stdout.write(out)
    sys.stderr.write(err)
    sys.stdout.write('Remove User\n')
    sys.stderr.write('Remove User\n')
    clt = process.client('sql', args = [os.path.join(dir, os.pardir,'drop_user.sql')], stdout = process.PIPE, stderr = process.PIPE)
    out,err = clt.communicate()
    sys.stdout.write(out)
    sys.stderr.write(err)
コード例 #46
0
import sys
try:
    from MonetDBtesting import process
except ImportError:
    import process

c = process.client('sql', stdin = process.PIPE,
                   stdout = process.PIPE, stderr = process.PIPE,
                   # these two to make client/server communication
                   # more efficient:
                   interactive = False, echo = False)
q = []
q.append(("create table bug3261 (probeid int, markername varchar(64));\n"
          "copy %d records into bug3261 from stdin using delimiters "
          "'\\t','\\n','' null as 'null';\n") % (1455 * 3916))
for i in xrange(1,1456):
    v = 'rmm%d' % i
    for j in xrange(3916):
        q.append('%d\t%s\n' % (j, v))
out, err = c.communicate(''.join(q))
sys.stdout.write(out)
sys.stderr.write(err)
c = process.client('sql', stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE)
out, err = c.communicate('select * from bug3261 where probeid = 1234 limit 10;\n')
sys.stdout.write(out)
sys.stderr.write(err)
c = process.client('sql', stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE)
out, err = c.communicate('drop table bug3261;\n')
sys.stdout.write(out)
sys.stderr.write(err)
コード例 #47
0
ファイル: wlc30.py プロジェクト: MonetDB/MonetDB
    from MonetDBtesting import process
except ImportError:
    import process
import os, sys

dbfarm = os.getenv('GDK_DBFARM')
tstdb = os.getenv('TSTDB')

if not tstdb or not dbfarm:
    print('No TSTDB or GDK_DBFARM in environment')
    sys.exit(1)

dbname = tstdb

s = process.server(dbname = dbname, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE)

c = process.client('sql', server = s, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE)

cout, cerr = c.communicate('''\
update tmp set i = 3 where i = 1;
update tmp set s = 'blah';
select * from tmp;
''')

sout, serr = s.communicate()

sys.stdout.write(sout)
sys.stdout.write(cout)
sys.stderr.write(serr)
sys.stderr.write(cerr)
コード例 #48
0
import os, sys
try:
    from MonetDBtesting import process
except ImportError:
    import process

c = process.client('sql',
                   args = [os.path.join(os.getenv('TSTSRCDIR'),
                                        '%s.txt' % sys.argv[1])],
                   stdout = process.PIPE, stderr = process.PIPE)
out, err = c.communicate()
sys.stdout.write(out)
sys.stderr.write(err)
コード例 #49
0
def client(file):
    sys.stderr.write('#client\n')
    sys.stderr.flush()
    clt = process.client('sql', stdin = open(file),
                         stdout = process.PIPE, stderr = process.PIPE)
    return clt.communicate()
コード例 #50
0
import os, sys
try:
    from MonetDBtesting import process
except ImportError:
    import process

clt = process.client('sql',
                     user='******',
                     passwd='p2',
                     stdin=open(
                         os.path.join(os.getenv('RELSRCDIR'), os.pardir,
                                      'role.sql')),
                     stdout=process.PIPE,
                     stderr=process.PIPE)
out, err = clt.communicate()
sys.stdout.write(out)
sys.stderr.write(err)
コード例 #51
0
import os, sys
try:
    from MonetDBtesting import process
except ImportError:
    import process

c = process.client('sql',
                   args = ['-s', '''CREATE USER "testuser" WITH PASSWORD \'password\' NAME \'Test User\' SCHEMA "sys";''' ],
                   stdout = process.PIPE,
                   stderr = process.PIPE)
out, err = c.communicate()
if out:
    sys.stdout.write(out)
if err:
    sys.stderr.write(err)

c = process.client('sql',
                   args = ['-s', 'CREATE GLOBAL TEMPORARY TABLE TempTable (i int);' ],
                   user = '******', passwd = 'password',
                   stdout = process.PIPE,
                   stderr = process.PIPE)
out, err = c.communicate()
if out:
    sys.stdout.write(out)
if err:
    sys.stderr.write(err)

c = process.client('sql',
                   args = ['-s', 'CREATE LOCAL TEMPORARY TABLE TempTable (i int); '],
                   user = '******', passwd = 'password',
                   stdout = process.PIPE,
コード例 #52
0
cloneport = freeport()

dbname = tstdb
dbnameclone = tstdb + '-clone'

#master = process.server(dbname = dbname, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE)
slave = process.server(dbname=dbnameclone,
                       mapiport=cloneport,
                       stdin=process.PIPE,
                       stdout=process.PIPE,
                       stderr=process.PIPE)

c = process.client('sql',
                   dbname=dbnameclone,
                   port=cloneport,
                   stdin=process.PIPE,
                   stdout=process.PIPE,
                   stderr=process.PIPE)

cout, cerr = c.communicate('''\
call replicate('%s',1);
select * from tmp;
''' % dbname)

sout, serr = slave.communicate()
#mout, merr = master.communicate()

#sys.stdout.write(mout)
sys.stdout.write(sout)
sys.stdout.write(cout)
#sys.stderr.write(merr)
コード例 #53
0
ファイル: dump.SQL.py プロジェクト: cswxu/monetdb-mcs
import sys
import re
try:
    from MonetDBtesting import process
except ImportError:
    import process

p = process.client('sqldump', stdout = process.PIPE, stderr = process.PIPE)
out, err = p.communicate()

pos = 0
for res in re.finditer(r'\b\d+\.\d{8,}\b', out):
    sys.stdout.write(out[pos:res.start(0)])
    sys.stdout.write('%.8g' % float(res.group(0)))
    pos = res.end(0)
sys.stdout.write(out[pos:])
sys.stderr.write(err)
コード例 #54
0
ファイル: Skyserver_v6.SQL.py プロジェクト: gsvic/MonetDB-1
def main():
    user = '******'
    passwd = 'skyserver'
    dir = os.getenv('TSTSRCDIR')
    sys.stdout.write('Create User\n')
    sys.stderr.write('Create User\n')
    with process.client('sql',
                        args=[os.path.join(dir, os.pardir, 'create_user.sql')],
                        stdout=process.PIPE,
                        stderr=process.PIPE) as clt:
        out, err = clt.communicate()
        sys.stdout.write(out)
        sys.stderr.write(err)
    sys.stdout.write('tables\n')
    sys.stderr.write('tables\n')
    with process.client(
            'sql',
            user=user,
            passwd=passwd,
            args=[os.path.join(dir, os.pardir, 'Skyserver_tables_v6.sql')],
            stdout=process.PIPE,
            stderr=process.PIPE) as clt1:
        out, err = clt1.communicate()
        sys.stdout.write(out)
        sys.stderr.write(err)
    with process.client('sql',
                        user='******',
                        passwd='monetdb',
                        stdin=process.PIPE,
                        stdout=process.PIPE,
                        stderr=process.PIPE) as clt1:
        sql = open(os.path.join(dir, os.pardir,
                                'Skyserver_import_v6.sql')).read().replace(
                                    'DATA_DIR',
                                    os.path.join(dir, os.pardir,
                                                 'microsky_v6').replace(
                                                     '\\', '\\\\'))
        out, err = clt1.communicate(sql)
        sys.stdout.write(out)
        sys.stderr.write(err)
    with process.client('sql',
                        user=user,
                        passwd=passwd,
                        args=[
                            os.path.join(dir, os.pardir,
                                         'Skyserver_constraints_v6.sql')
                        ],
                        stdout=process.PIPE,
                        stderr=process.PIPE) as clt1:
        out, err = clt1.communicate()
        sys.stdout.write(out)
        sys.stderr.write(err)
    sys.stdout.write('views\n')
    sys.stderr.write('views\n')
    with process.client(
            'sql',
            user=user,
            passwd=passwd,
            args=[os.path.join(dir, os.pardir, 'Skyserver_views_v6.sql')],
            stdout=process.PIPE,
            stderr=process.PIPE) as clt1:
        out, err = clt1.communicate()
        sys.stdout.write(out)
        sys.stderr.write(err)
    sys.stdout.write('functions\n')
    sys.stderr.write('functions\n')
    with process.client(
            'sql',
            user=user,
            passwd=passwd,
            args=[os.path.join(dir, os.pardir, 'Skyserver_functions_v6.sql')],
            stdout=process.PIPE,
            stderr=process.PIPE) as clt1:
        out, err = clt1.communicate()
        sys.stdout.write(out)
        sys.stderr.write(err)
    sys.stdout.write('Cleanup\n')
    sys.stderr.write('Cleanup\n')
    with process.client('sql',
                        user=user,
                        passwd=passwd,
                        args=[
                            os.path.join(dir, os.pardir,
                                         'Skyserver_dropFunctions_v6.sql')
                        ],
                        stdout=process.PIPE,
                        stderr=process.PIPE) as clt1:
        out, err = clt1.communicate()
        sys.stdout.write(out)
        sys.stderr.write(err)
    with process.client(
            'sql',
            user=user,
            passwd=passwd,
            args=[os.path.join(dir, os.pardir, 'Skyserver_dropViews_v6.sql')],
            stdout=process.PIPE,
            stderr=process.PIPE) as clt1:
        out, err = clt1.communicate()
        sys.stdout.write(out)
        sys.stderr.write(err)
    with process.client('sql',
                        user=user,
                        passwd=passwd,
                        args=[
                            os.path.join(dir, os.pardir,
                                         'Skyserver_dropConstraints_v6.sql')
                        ],
                        stdout=process.PIPE,
                        stderr=process.PIPE) as clt1:
        out, err = clt1.communicate()
        sys.stdout.write(out)
        sys.stderr.write(err)
    with process.client(
            'sql',
            user=user,
            passwd=passwd,
            args=[os.path.join(dir, os.pardir, 'Skyserver_dropTables_v6.sql')],
            stdout=process.PIPE,
            stderr=process.PIPE) as clt1:
        out, err = clt1.communicate()
        sys.stdout.write(out)
        sys.stderr.write(err)
    sys.stdout.write('Remove User\n')
    sys.stderr.write('Remove User\n')
    with process.client('sql',
                        args=[os.path.join(dir, os.pardir, 'drop_user.sql')],
                        stdout=process.PIPE,
                        stderr=process.PIPE) as clt:
        out, err = clt.communicate()
        sys.stdout.write(out)
        sys.stderr.write(err)
コード例 #55
0
ファイル: check.SQL.py プロジェクト: MonetDB/MonetDB
import os, sys, re
try:
    from MonetDBtesting import process
except ImportError:
    import process

clt = process.client('sql', format='csv', echo=False,
                     stdin=process.PIPE, stdout=process.PIPE, stderr=process.PIPE)

for c in 'ntvsf':
    clt.stdin.write("select '\\\\d%s';\n" % c)

for c in 'ntvsf':
    clt.stdin.write("select '\\\\dS%s';\n" % c)

clt.stdin.write("select '\\\\dn ' || name from sys.schemas order by name;\n")

clt.stdin.write("select '\\\\dSt ' || s.name || '.' || t.name from sys._tables t, sys.schemas s where t.schema_id = s.id and t.query is null order by s.name, t.name;\n")

clt.stdin.write("select '\\\\dSv ' || s.name || '.' || t.name from sys._tables t, sys.schemas s where t.schema_id = s.id and t.query is not null order by s.name, t.name;\n")

clt.stdin.write("select distinct '\\\\dSf ' || s.name || '.\"' || f.name || '\"' from sys.functions f, sys.schemas s where f.language between 1 and 2 and f.schema_id = s.id and s.name = 'sys' order by s.name, f.name;\n")

out, err = clt.communicate()
out = re.sub('^"(.*)"$', r'\1', out, flags=re.MULTILINE).replace('"\n', '\n').replace('\n"', '\n').replace('""', '"').replace(r'\\', '\\')

sys.stdout.write(out)
sys.stderr.write(err)

clt = process.client('sql', interactive=True,
                     stdin=process.PIPE, stdout=process.PIPE, stderr=process.PIPE)
コード例 #56
0
import os, sys
try:
    from MonetDBtesting import process
except ImportError:
    import process

TSTSRCDIR = os.environ['TSTSRCDIR']
DATADIR = os.path.join(TSTSRCDIR, "SF-0.01") + os.sep.replace('\\', r'\\')

c = process.client('sql',
                   stdin=process.PIPE,
                   stdout=process.PIPE,
                   stderr=process.PIPE)
for ln in open(os.path.join(TSTSRCDIR, "load-sf-0.01.sql")):
    c.stdin.write(ln.replace('PWD/', DATADIR))
out, err = c.communicate()
sys.stdout.write(out)
sys.stderr.write(err)

c = process.client('sql',
                   stdin=open(os.path.join(TSTSRCDIR, "check1.sql")),
                   stdout=process.PIPE,
                   stderr=process.PIPE)
out, err = c.communicate()
sys.stdout.write(out)
sys.stderr.write(err)
コード例 #57
0
ファイル: load.SQL.py プロジェクト: digideskio/monetdb
import os, sys
try:
    from MonetDBtesting import process
except ImportError:
    import process

TSTSRCDIR = os.environ['TSTSRCDIR']
DATADIR = os.path.join(TSTSRCDIR,"SF-0.01") + os.sep.replace('\\', r'\\')

c = process.client('sql', stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE)
for ln in open(os.path.join(TSTSRCDIR,"load-sf-0.01.sql")):
    c.stdin.write(ln.replace('PWD/', DATADIR))
out, err = c.communicate()
sys.stdout.write(out)
sys.stderr.write(err)

c = process.client('sql', stdin = open(os.path.join(TSTSRCDIR,"check1.sql")), stdout = process.PIPE, stderr = process.PIPE)
out, err = c.communicate()
sys.stdout.write(out)
sys.stderr.write(err)
コード例 #58
0
def client(input):
    c = process.client('sql', stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE)
    out, err = c.communicate(input)
    sys.stdout.write(out)
    sys.stderr.write(err)
コード例 #59
0
def sql_test_client(user, passwd, input):
    process.client(lang = "sql", user = user, passwd = passwd, communicate = True,
                   stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE,
                   input = input, port = int(os.getenv("MAPIPORT")))
コード例 #60
0
    from MonetDBtesting import process
except ImportError:
    import process
import os, sys

dbfarm = os.getenv('GDK_DBFARM')
tstdb = os.getenv('TSTDB')

if not tstdb or not dbfarm:
    print('No TSTDB or GDK_DBFARM in environment')
    sys.exit(1)

dbname = tstdb

s = process.server(dbname = dbname, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE)

c = process.client('sql', dbname = dbname, stdin = process.PIPE, stdout = process.PIPE, stderr = process.PIPE)

cout, cerr = c.communicate('''\
update tmp set i = 3 where i = 1;
update tmp set s = 'blah';
select * from tmp;
''')

sout, serr = s.communicate()

sys.stdout.write(sout)
sys.stdout.write(cout)
sys.stderr.write(serr)
sys.stderr.write(cerr)