コード例 #1
0
    def execute_no_reconnect(self, command, silent=True):
        statement = sql.parse("sql", command)
        if statement == None:
            return "You have an error in your SQL syntax\n"
        statement.sort = self.sort

        payload = statement.pack()
        header = struct.pack("<lll", statement.reqeust_type, len(payload), 0)

        self.socket.sendall(header)
        if len(payload):
            self.socket.sendall(payload)

        IPROTO_HEADER_SIZE = 12

        header = self.recvall(IPROTO_HEADER_SIZE)

        response_len = struct.unpack("<lll", header)[1]

        if response_len:
            response = self.recvall(response_len)
        else:
            response = None

        if not silent:
            print command
            print statement.unpack(response)

        return statement.unpack(response) + "\n"
コード例 #2
0
    def execute_no_reconnect(self, command, silent=True):
        statement = sql.parse("sql", command)
        if statement == None:
            return "You have an error in your SQL syntax\n"
        statement.sort = self.sort
 
        response = None
        request = statement.pack(self.py_con)
        with warnings.catch_warnings():
            warnings.simplefilter("ignore")
            response = self.py_con._send_request(request, False)

        if not silent:
            print command
            print statement.unpack(response)

        return statement.unpack(response)
コード例 #3
0
    def execute_no_reconnect(self, command, silent=True):
        statement = sql.parse("sql", command)
        if statement == None:
            return "You have an error in your SQL syntax\n"
        statement.sort = self.sort
 
        response = None
        request = statement.pack(self.py_con)
        with warnings.catch_warnings():
            warnings.simplefilter("ignore")
            response = self.py_con._send_request(request, False)

        if not silent:
            print command
            print statement.unpack(response)

        return statement.unpack(response)
コード例 #4
0
def test_parse_postgresql_socket_connection():
    assert parse("postgresql:///shakes SELECT * FROM work") == \
           {'connection': "postgresql:///shakes",
            'sql': 'SELECT * FROM work'}
コード例 #5
0
def test_parse_sql_only():
    assert parse("SELECT * FROM work") == \
           {'connection': "",
            'sql': 'SELECT * FROM work'}
コード例 #6
0
def test_parse_with_sql():
    assert parse("postgresql://*****:*****@localhost/shakes SELECT * FROM work") == \
           {'connection': "postgresql://*****:*****@localhost/shakes",
            'sql': 'SELECT * FROM work'}
コード例 #7
0
def test_parse_no_sql():
    assert parse("will:longliveliz@localhost/shakes") == \
           {'connection': "will:longliveliz@localhost/shakes",
            'sql': ''}
コード例 #8
0
ファイル: allPythonContent.py プロジェクト: Mondego/pyreco
def test_parse_postgresql_socket_connection():
    assert parse("postgresql:///shakes SELECT * FROM work") == {
        "connection": "postgresql:///shakes",
        "sql": "SELECT * FROM work",
    }
コード例 #9
0
ファイル: allPythonContent.py プロジェクト: Mondego/pyreco
def test_parse_sql_only():
    assert parse("SELECT * FROM work") == {"connection": "", "sql": "SELECT * FROM work"}
コード例 #10
0
ファイル: allPythonContent.py プロジェクト: Mondego/pyreco
def test_parse_with_sql():
    assert parse("postgresql://*****:*****@localhost/shakes SELECT * FROM work") == {
        "connection": "postgresql://*****:*****@localhost/shakes",
        "sql": "SELECT * FROM work",
    }
コード例 #11
0
ファイル: allPythonContent.py プロジェクト: Mondego/pyreco
def test_parse_no_sql():
    assert parse("will:longliveliz@localhost/shakes") == {"connection": "will:longliveliz@localhost/shakes", "sql": ""}