Ejemplo n.º 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"
Ejemplo 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)
Ejemplo n.º 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)
Ejemplo n.º 4
0
def test_parse_postgresql_socket_connection():
    assert parse("postgresql:///shakes SELECT * FROM work") == \
           {'connection': "postgresql:///shakes",
            'sql': 'SELECT * FROM work'}
Ejemplo n.º 5
0
def test_parse_sql_only():
    assert parse("SELECT * FROM work") == \
           {'connection': "",
            'sql': 'SELECT * FROM work'}
Ejemplo n.º 6
0
def test_parse_with_sql():
    assert parse("postgresql://*****:*****@localhost/shakes SELECT * FROM work") == \
           {'connection': "postgresql://*****:*****@localhost/shakes",
            'sql': 'SELECT * FROM work'}
Ejemplo n.º 7
0
def test_parse_no_sql():
    assert parse("will:longliveliz@localhost/shakes") == \
           {'connection': "will:longliveliz@localhost/shakes",
            'sql': ''}
Ejemplo n.º 8
0
def test_parse_postgresql_socket_connection():
    assert parse("postgresql:///shakes SELECT * FROM work") == {
        "connection": "postgresql:///shakes",
        "sql": "SELECT * FROM work",
    }
Ejemplo n.º 9
0
def test_parse_sql_only():
    assert parse("SELECT * FROM work") == {"connection": "", "sql": "SELECT * FROM work"}
Ejemplo n.º 10
0
def test_parse_with_sql():
    assert parse("postgresql://*****:*****@localhost/shakes SELECT * FROM work") == {
        "connection": "postgresql://*****:*****@localhost/shakes",
        "sql": "SELECT * FROM work",
    }
Ejemplo n.º 11
0
def test_parse_no_sql():
    assert parse("will:longliveliz@localhost/shakes") == {"connection": "will:longliveliz@localhost/shakes", "sql": ""}