nuodb / nuodb-python Goto Github PK
View Code? Open in Web Editor NEWPure-python SQL driver implementation.
License: BSD 3-Clause "New" or "Revised" License
Pure-python SQL driver implementation.
License: BSD 3-Clause "New" or "Revised" License
I tried to add a test to perform an invalid batch operation and got my exception but then the next operation crashed on the nice raise SessionException('no') when trying to do the next _putMessageId
Create a table like this:
sql.execute("CREATE TABLE t1_binary ( f1 BINARY, f2 BINARY(5), f3 VARBINARY(5), f4 BINARY LARGE OBJECT, f5 BLOB (5K));")
sql.execute("INSERT INTO t1_binary VALUES ('a',0x12345678,'abc','abc','abc');")
And then try to select * from it over the pynuodb driver, you get:
DataError: 'received unknown column type from the database "binary varying"'
this is unexpected
Currently Cursor.fetchmany and Cursor.fetchall work by calling Cursor.fetchone the appropriate number of times. This ok, since fetchone gets results from the server in chunks and only makes another request to the server when the current chunk is exhausted. However, as an optimization fetchmany and fetchall could immediately fetch the appropriate number of rows from the database.
This call:
con = pynuodb.connect("test", "localhost", "dba", "goalie", port = 23456, schema="hockey")
succeeds even though no server is listening on port 23456
Currently there are several files that have unused variables and methods in them, these should be cleaned up for clarity.
The README is very minimal: it should specify that nuodb-python intends to comply with PEP 249 and provide a link to it, so users can get more details easily.
Traceback (most recent call last):
File "/home/treilly/nuodb/DebugTools/memprof.py", line 32, in
str = p.query("Memory", ElementTree.fromstring(""))
File "/usr/local/lib/python2.7/dist-packages/pynuodb/entity.py", line 951, in query
"Database" : self.database.name })
File "/usr/local/lib/python2.7/dist-packages/pynuodb/session.py", line 149, in doRequest
checkForError(response)
File "/usr/local/lib/python2.7/dist-packages/pynuodb/session.py", line 56, in checkForError
raise SessionException(root.get("text"))
pynuodb.session.SessionException: 'Unknown management type: GetDatabaseCredentials'
This will result in leaks on the server side (for the duration of the connection)
The type code values used in encodedsession.py should be constants in protocol.py
Every row in the param list can succeed or fail independently and the client needs to be able to know which failed and which succeeded. It appears the current implemenatation will fail to read all the data which can lead to data left in the connection and result in protocol errors. In JDBC you use BatchUpdateException.getUpdateCounts() to get the results for all operations to figure out which failed and which proceeded. In JDBC a database can chose to stop after the first failure but NuoDB doesn't do that and the protocol is that a result is returned for each element of the batch (with an extra int and string if the result is -3).
putScaledCount2
encodes value
with toSignedByteString
as well as sending the sign as the string "1" or "-1". This seems redundant. Why send "1" or "-1" when toSignedByteString
is used?
The code below will throw the following error when attempting to retrieve the Double Precision datatype from the Employee Table.
ERROR:
Traceback (most recent call last):
File "pynuodbDblPrecision.py", line 28, in
cursor.execute("select * from employee")
File "/Library/Python/2.7/site-packages/pynuodb/cursor.py", line 118, in execute
row[i] = self.session.getValue()
File "/Library/Python/2.7/site-packages/pynuodb/encodedsession.py", line 443, in getValue
return self.getDouble()
File "/Library/Python/2.7/site-packages/pynuodb/encodedsession.py", line 317, in getDouble
return struct.unpack('d', self._takeBytes(typeCode - 77))[0]
struct.error: unpack requires a string argument of length 8
CODE
import pynuodb
# open database connecton
connection = pynuodb.connect("test", "localhost", "dba", "goalie", schema='hockey')
# Prepare the cursor object
cursor = connection.cursor()
# Drop table if it already exist using execute() method.
cursor.execute("DROP TABLE IF EXISTS EMPLOYEE")
#Create Table
cursor.execute("CREATE TABLE EMPLOYEE(FIRST_NAME CHAR (20) NOT NULL, LAST_NAME CHAR (20),INCOME DOUBLE PRECISION)")
#Insert
cursor.execute("INSERT INTO EMPLOYEE (FIRST_NAME,LAST_NAME,INCOME)VALUES('August','Adamonis',2000000)")
connection.commit()
cursor.execute("select * from employee")
# Print the output
print cursor.fetchall()
# disconnect from server
connection.close()
NOTE: the error will occur if Real, Float or Double Precision are used.
Current the test suite for nuodb-python uses the pynuodb.entity module to create and manage a database for the test. This is no longer feasible since the NuoDB Agent layer is deprecated in NuoDB 4.0 and will be obsolete in an upcoming release.
The tests need to be rewritten to either (a) use the pynuoadmin module to create and manage the database, or (b) presume that an appropriate database has already been created and use that for testing.
python run_tests.py
...........F.......F...................................................
======================================================================
FAIL: test_param_date_types (tests.nuodb_basic_test.NuoDBBasicTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/philips/git/nuodb-python/tests/nuodb_basic_test.py", line 465, in test_param_date_types
self.assertEqual(row[2].hour, test_vals[1].hour)
AssertionError: 10 != 0
======================================================================
FAIL: test_string_into_number (tests.nuodb_basic_test.NuoDBBasicTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/philips/git/nuodb-python/tests/nuodb_basic_test.py", line 287, in test_string_into_number
self.assertEqual(row[0], decimal.Decimal(test_vals[0]))
AssertionError: '54.4978' != Decimal('54.4978')
----------------------------------------------------------------------
Ran 71 tests in 13.016s
Githalitics is dead and the link now points to a known viral malicious site. Please delete the link at the bottom of the page.
Is sending a scaled time as a unsigned byte string correct?
nuodb-python/pynuodb/encodedsession.py
Line 494 in 979c80d
Let's assume the time we're trying to encode is 1 minute after midnight, local time; local time offset is negative 1 hour (perhaps we're in Western Europe).
Here we add the offset of the local timezone, which is negative (as described in the python documentation, offsets may be negative). So now our value is (-59 minutes * 60 seconds/minute) = -3540. Then we use toByteString
to encode that negative value.
I have not tested any of this by hand, but this seems like a possible error to me.
The dotnet driver encodes scaled time as a signed byte string, if I'm reading it correctly.
Please remove : [email protected]
nuodb-python/pynuodb/protocol.py
Line 63 in ac04ead
Reusing statements saves roundtrips to the server.
In https://github.com/nuodb/nuodb-python/blob/master/pynuodb/encodedsession.py open_database()
the protocol version is set as protocol.EXECUTEPREPAREDUPDATE
which is 24.
There is no protocol 24, so we should add some constants to the protocol file for the versions and update open_database()
to use the correct one (which is likely 14)
The connection module does not validate the schema argument when connecting to the database.
E.G.
import pynuodb
connection = pynuodb.connect(database="test", host="localhost", user="dba", password="goalie", schema='SPAM')
connection.close()
The above example does not throw an error however, arguably, it should since the other arguments are validated when the connection is made and throw an appropriate error.
Schema is validated if the code has an actual query which makes sense since schema is in use;
E.G.
import pynuodb
connection = pynuodb.connect(database="test", host="localhost", user="dba", password="goalie", schema='SPAM')
cursor = connection.cursor()
cursor.arraysize = 3
cursor.execute("select * from hockey")
print cursor.fetchone()
ERROR
Traceback (most recent call last):
File "/Users/dadamonis/Documents/nuoDB/python/testDriver.py", line 6, in
cursor.execute("select * from hockey")
File "/Library/Python/2.7/site-packages/pynuodb/cursor.py", line 92, in execute
self._execute(operation)
File "/Library/Python/2.7/site-packages/pynuodb/cursor.py", line 164, in _execute
self.session.exchangeMessages()
File "/Library/Python/2.7/site-packages/pynuodb/encodedsession.py", line 492, in
exchangeMessages
raise DatabaseError('Non-zero status: %s' % self.getString())
pynuodb.exception.DatabaseError: 'Non-zero status: can't find table "HOCKEY"\nSQL:
select * from hockey'
For different errors in connect(), vastly different exceptions are thrown. I think it may be better to standardize them somehow so that they can all be handled uniformly:
encodedsession.py raises NotImplementedError when a query is performed that requires a scaled date or time.
The top-level connect() function needs to take a different argument list:
The key-value pairs are the properties that we allow on a client connection. The properties cannot be hidden behind this routine, because there are many cases where the caller needs to pass them in.
If the schema needs to be specified for some reason then let's talk about what the default should be and why. Right now this is following different behavior than our other drivers.
con.auto_commit = False does not cause autocommit to be disabled:
con = self._connect();
con.auto_commit = False;
self.assertEquals(con.auto_commit, False);
cursor1.execute("INSERT INTO autocommit_set VALUES (1)");
cursor2.execute("SELECT COUNT(*) FROM autocommit_set");
self.assertEquals(cursor2.fetchone()[0], 0);
Shutting down a database on windows causes the follow error:
Traceback (most recent call last):
File "tests/nuodb_entity_test.py", line 27, in setUp
self._cleanup(domain)
File "tests/nuodb_entity_test.py", line 338, in _cleanup
db.shutdown()
File "c:\Python27\lib\site-packages\pynuodb\entity.py", line 467, in shutdown
self.quiesce()
File "c:\Python27\lib\site-packages\pynuodb\entity.py", line 502, in quiesce
self.__name, DatabaseAction.Quiesce)
File "c:\Python27\lib\site-packages\pynuodb\util.py", line 106, in doDatabaseA
ction
checkForError(response)
File "c:\Python27\lib\site-packages\pynuodb\session.py", line 56, in checkForE
rror
raise SessionException(root.get("text"))
SessionException: 'WIN-LCFGI29L425.localdomain'
These are necessary to implement consistency across multiple connections from a particular client, first step is to probably write down somewhere what the rules are and them implement them.
The GENHTML mnemonic in protocol.py is declared differently in two places. I cannot see how this can possibly be a good thing.
This is a new feature in 2.2 that allows a host to be put into maintenance mode so that the enforcer doesn't try to start processes on it. We have yet to add python support for it.
Currently encodedsession.excheangeMessages() will always raise a DatabaseError on nonzero response status. Specific nonzero response codes should be mapped to the appropriate children of DatabaseError.
Statements such as:
cursor.execute("SELECT ? FROM DUAL");
cursor.execute("SELECT ?, ? FROM DUAL", []);
must fail with an exception such as "wrong number of parameters specified, expected X got Y". Otherwise, simple typos may lead to data loss or wrong results.
Others fail with an exception "TypeError: init() takes exactly 2 arguments (1 given)" which is not very informative.
The one issue all tests run into when running with Python 3:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pynuodb/entity.py:69: in __init__
self.__session.authorize(domain_user, domain_pwd)
pynuodb/session.py:110: in authorize
cp = ClientPassword()
pynuodb/crypt.py:135: in __init__
self.__group = RemoteGroup()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pynuodb.crypt.RemoteGroup object at 0x101efe518>
primeStr = 'EEAF0AB9ADB38DD69C33F80AFA8FC5E86072618775FF3C0B9EA2314C9C256576D674DF7496EA81D3383B4813D692C6E0E0D5D8E250B98BE48E495...54D6B6CE8EF4AD69B15D4982559B297BCF1885C529F566660E57EC68EDBC3C05726CC02FD4CBF4976EAA9AFD5138FE8376435B9FC61D2FC0EB06E3'
generatorStr = '2'
def __init__(self, primeStr=defaultPrime, generatorStr=defaultGenerator):
self.__primeInt = fromHex(primeStr)
self.__generatorInt = fromHex(generatorStr)
primeBytes = toByteString(self.__primeInt)
generatorBytes = toByteString(self.__generatorInt)
paddingLength = len(primeBytes) - len(generatorBytes)
md = hashlib.sha1()
> md.update(primeBytes)
E TypeError: Unicode-objects must be encoded before hashing
pynuodb/crypt.py:116: TypeError
When rewriting or fixing this driver, please use syntax supported by more than one virtual of Python; using virtualenv to support testing assert the driver installs for both 3.4.3 and 2.7.6 without issue and tests satisfactorily.
Thank you.
When a prepared statement is executed more than once the statement should be cached and executed from cache. This functionality can be observed with the SQL client, but it's not working when the statements are executed via the python driver.
You can start the database like so:
'''
killall java nuodb
java -jar ~/nuodb/dist/jar/nuoagent.jar --broker --password bird &
~/nuodb/dist/bin/nuodbmgr --broker localhost --password bird --command "shutdown database test timeout 2m softTimeout 2m"
rm -rf /tmp/test
~/nuodb/dist/bin/nuodbmgr --broker localhost --password bird --command "start process sm database test host localhost:48004 archive /tmp/test initialize true"
~/nuodb/dist/bin/nuodbmgr --broker localhost --password bird --command "start process te database test host localhost:48004 options '--dba-user dba --dba-password dba'"
~/nuodb/dist/bin/nuodbmgr --broker localhost --password bird --command "show domain summary"
To connect to the SQL client and try something manually: ~/nuodb/dist/bin/nuosql test@localhost:48004 --user dba --password dba
'''
And use the following script to verify the functionality:
'''
import pynuodb
import time
def executeStatement(cursor, statement, prepared=None, fetch=False):
if prepared is not None:
print statement, ' ', prepared
if len(prepared) > 1:
cursor.executemany(statement, prepared)
else:
cursor.execute(statement, prepared)
else:
print statement
cursor.execute(statement)
if fetch == True:
for row in cursor.fetchall():
print row
options = {"schema": "test"}
connect_kw_args = {'database': "test", 'host': "localhost:48004", 'user': "dba", 'password': "dba", 'options': options}
connection = pynuodb.connect(**connect_kw_args)
cursor = connection.cursor()
executeStatement(cursor, 'autocommit on;')
tableName = 'SimpleTable'
executeStatement(cursor, 'DROP TABLE IF EXISTS %s;' % tableName)
executeStatement(cursor, 'CREATE TABLE %s (%s);' % (tableName, 'f1 INTEGER'))
executeStatement(cursor, 'INSERT INTO SimpleTable VALUES (?),(?);', prepared=[(1, 1),(1, 1),(1, 1)])
executeStatement(cursor, 'INSERT INTO SimpleTable VALUES (?),(?);', prepared=[(1, 1),(1, 1),(1, 1)])
executeStatement(cursor, 'INSERT INTO SimpleTable VALUES (?),(?);', prepared=[(1, 1),(1, 1),(1, 1)])
executeStatement(cursor, 'INSERT INTO SimpleTable VALUES (?),(?);', prepared=[(1, 1),(1, 1),(1, 1)])
executeStatement(cursor, 'INSERT INTO SimpleTable VALUES (?);', prepared=[1])
executeStatement(cursor, 'INSERT INTO SimpleTable VALUES (?);', prepared=[1])
executeStatement(cursor, 'INSERT INTO SimpleTable VALUES (?);', prepared=[1])
executeStatement(cursor, 'INSERT INTO SimpleTable VALUES (?);', prepared=[1])
executeStatement(cursor, 'SELECT * from %s;' % tableName)
executeStatement(cursor, 'SELECT * from %s;' % tableName)
executeStatement(cursor, 'SELECT * from %s;' % tableName)
executeStatement(cursor, 'SELECT * from %s;' % tableName)
print ''
print ''
executeStatement(cursor, 'select CACHEHITS, STATEMENT from system.localstatements where statement not like '%system%';', fetch=True)
cursor.close()
connection.close()
'''
The output at the moment (2018.09.27) shows:
'''
autocommit on;
DROP TABLE IF EXISTS SimpleTable;
CREATE TABLE SimpleTable (f1 INTEGER);
INSERT INTO SimpleTable VALUES (?),(?); [(1, 1), (1, 1), (1, 1)]
INSERT INTO SimpleTable VALUES (?),(?); [(1, 1), (1, 1), (1, 1)]
INSERT INTO SimpleTable VALUES (?),(?); [(1, 1), (1, 1), (1, 1)]
INSERT INTO SimpleTable VALUES (?),(?); [(1, 1), (1, 1), (1, 1)]
INSERT INTO SimpleTable VALUES (?); [1]
INSERT INTO SimpleTable VALUES (?); [1]
INSERT INTO SimpleTable VALUES (?); [1]
INSERT INTO SimpleTable VALUES (?); [1]
SELECT * from SimpleTable;
SELECT * from SimpleTable;
SELECT * from SimpleTable;
SELECT * from SimpleTable;
select CACHEHITS, STATEMENT from system.localstatements where statement not like '%system%';
(3, 'SELECT * from SimpleTable;')
(0, 'INSERT INTO SimpleTable VALUES (?),(?);')
(0, 'INSERT INTO SimpleTable VALUES (?);')
'''
The values for CACHEHITS for the prepared statements should be 3.
I know this is true for executemany, not sure if there are other places its not implemented
We may want to revise the test cases in test_enotation_decimal_large. Values passed to the database are converted from e notation to decimal and passed back in decimal, despite this the assert statements are checking for the value in e notation, thus the test asserts.
From testing, NuoSQL responds the same way as the driver with returning a decimal value.
second definition
nuodb-python/pynuodb/protocol.py
Line 160 in 979c80d
When inserting the value decimal.Decimal("31943874831932418390.01") into a numeric column, the database responds with the error 'INVALID_UTF8: invalid UTF-8 code sequence'
This could be an encoding error on the send side of the driver, or an error in the database itself.
Traceback (most recent call last):
File "/home/travis/build/nuodb/nuodb-python/tests/nuodb_basic_test.py", line 160, in test_many_significant_digits
self._test_decimal_fixture(decimal.Decimal("31943874831932418390.01"), 38, 12)
File "/home/travis/build/nuodb/nuodb-python/tests/nuodb_basic_test.py", line 139, in _test_decimal_fixture
cursor.execute("INSERT INTO t (x) VALUES (?)", (value,))
File "/home/travis/build/nuodb/nuodb-python/pynuodb/cursor.py", line 116, in execute
exec_result = self._executeprepared(operation, parameters)
File "/home/travis/build/nuodb/nuodb-python/pynuodb/cursor.py", line 142, in _executeprepared
return self.session.execute_prepared_statement(p_statement, parameters)
File "/home/travis/build/nuodb/nuodb-python/pynuodb/encodedsession.py", line 217, in execute_prepared_statement
self._exchangeMessages()
File "/home/travis/build/nuodb/nuodb-python/pynuodb/encodedsession.py", line 796, in _exchangeMessages
db_error_handler(error, self.getString())
File "/home/travis/build/nuodb/nuodb-python/pynuodb/exception.py", line 86, in db_error_handler
raise DataError(error_code_string + ': ' + error_string)
DataError: 'INVALID_UTF8: invalid UTF-8 code sequence'
Commonly developers will have several databases running when doing development. The test harness tries to go off and shutdown ALL databases; this should never be done.
tests/nuodb_entity_test.py:381: Exception
____________________________________________________ NuoDBEntityTest.test_shutdownDomain ____________________________________________________
self = <tests.nuodb_entity_test.NuoDBEntityTest testMethod=test_shutdownDomain>
def setUp(self):
self.host = BROKER_HOST + (':'+os.environ['NUODB_PORT'] if 'NUODB_PORT' in os.environ else '')
domain = Domain(self.host, DOMAIN_USER, DOMAIN_PASSWORD)
> self._cleanup(domain)
tests/nuodb_entity_test.py:33:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <tests.nuodb_entity_test.NuoDBEntityTest testMethod=test_shutdownDomain>, domain = <pynuodb.entity.Domain instance at 0x10dd59dd0>
def _cleanup(self, domain):
if domain is not None:
try:
db_names = [db.name for db in domain.databases]
for name in db_names:
db = domain.get_database(name)
db.shutdown()
i = 0
while len(db.processes) > 0 and i < 10:
time.sleep(1)
i += 1
if domain.get_database(name) is not None:
> raise Exception("Could not shutdown existing test database %s" % (name))
E Exception: Could not shutdown existing test database ref
It seems that if query params are not provided the query statement with a ? in it works when it should not. Take the Greg-Marsha-Jan sample on the README and pass in no second argument to the execute call -- it returns the full table, when it should have errorred.
import pynuodb
options = {"schema": "test"}
connect_kw_args = {'database': "test", 'host': "localhost", 'user': "dba", 'password': "dba", 'options': options}
connection = pynuodb.connect(**connect_kw_args)
cursor = connection.cursor()
stmt_drop = "DROP TABLE IF EXISTS names"
cursor.execute(stmt_drop)
stmt_create = """
CREATE TABLE names (
id BIGINT NOT NULL GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
name VARCHAR(30) DEFAULT '' NOT NULL,
age INTEGER DEFAULT 0
)"""
cursor.execute(stmt_create)
names = (('Greg', 17,), ('Marsha', 16,), ('Jan', 14,))
stmt_insert = "INSERT INTO names (name, age) VALUES (?, ?)"
cursor.executemany(stmt_insert, names)
connection.commit()
age_limit = 15
stmt_select = "SELECT id, name FROM names where age > ? ORDER BY id"
# cursor.execute(stmt_select, (age_limit,)) # works, and correct
cursor.execute(stmt_select) # <<< WORKS BUT SHOULD HAVE FAILED <<<
print("Results:")
for row in cursor.fetchall():
print("%d | %s" % (row[0], row[1]))
cursor.execute(stmt_drop)
cursor.close()
connection.close()
If you pass a unicode object, rather than a str object, to execute() (etc.) then you'll get a bizarre exception from Cryptography:
File "nuodb-python/pynuodb/cursor.py", line 120, in execute
exec_result = self._execute(operation)
File "nuodb-python/pynuodb/cursor.py", line 153, in _execute
return self.session.execute_statement(self._statement_cache.get_statement(), operation)
File "nuodb-python/pynuodb/encodedsession.py", line 309, in execute_statement
self._exchangeMessages()
File "nuodb-python/pynuodb/encodedsession.py", line 1073, in _exchangeMessages
self.send(self.__output)
File "nuodb-python/pynuodb/session.py", line 351, in send
message = self.__cipherOut.transform(message)
File "nuodb-python/pynuodb/crypt.py", line 321, in transform
transformed = self.cipher.update(data)
File "/usr/lib/python2.7/site-packages/cryptography/hazmat/primitives/ciphers/base.py", line 149, in update
return self._ctx.update(data)
File "/usr/lib/python2.7/site-packages/cryptography/hazmat/backends/openssl/ciphers.py", line 124, in update
n = self.update_into(data, buf)
File "/usr/lib/python2.7/site-packages/cryptography/hazmat/backends/openssl/ciphers.py", line 140, in update_into
self._backend._ffi.from_buffer(data), len(data)
TypeError: from_buffer() cannot return the address of a unicode object
To declare a dependency I have to add -REL rather than just use the version number:
-pynuodb>=2.3
+pynuodb>=2.3-REL
This regards the files posted on py.pi:
pynuodb-2.3-REL.tar.gz (md5)
When the file name ought to have been:
pynuodb-2.3.tar.gz (md5)
from pynuodb import connect
db = connect('test', 'localhost', 'dba', 'dba')
c = db.cursor()
c.execute('select * from system.connections')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/pynuodb/cursor.py", line 142, in execute
row[i] = self.session.getValue()
File "/Library/Python/2.7/site-packages/pynuodb/encodedsession.py", line 443, in getValue
return self.getUUID()
File "/Library/Python/2.7/site-packages/pynuodb/encodedsession.py", line 425, in getUUID
raise DataError('Not a UUID')
pynuodb.exception.DataError: 'Not a UUID'
To work around this, skip the "EXECID" column.
SQL> show system.connections;
Tables named CONNECTIONS
Found table CONNECTIONS in schema SYSTEM
Fields:
SQLSTRING string
COUNT integer
RUNTIME bigint
USER string
SCHEMA string
NUMPARAM integer
PARAMS string
CONNID integer
OPEN integer
HANDLE integer
NODEID integer
EXECID numeric(20)
This code:
con = pynuodb.connect("test", "localhost", "dba", "goalie", schema="hockey");
con.auto_commit = True;
causes the driver to hang
strace shows that pyton is hung waiting on recvfrom() from the server. The server however seems to also be waiting for a message.
If we make a request where the headers (the labels on the columns) of the result set are larger than a single result set return value (100,000 bytes), then the python driver will throw an incorrect EndOfStream() exception.
In the current implementation of the python driver you are unable to insert a date or datetime that has a year prior to 1902 without getting an error. Additionally if a year is already present in the database prior to 1884 then these values may be incorrect when retrieved by the python driver.
When I execute a SELECT statement, I do get the rows back like I expected, but I was also wanting to see the names of the columns in the response.
Here is my code I'm testing with
import pynuodb
options = {'schema': "MY_SCHEMA"}
connect_kw_args = {'database': "MY_DB", 'host': "MY_HOST", 'user': "MY_USER", 'password': "MY_PW", 'options': options}
connection = pynuodb.connect(**connect_kw_args)
cursor = connection.cursor()
stmt_select = "SELECT * FROM Money LIMIT 2"
cursor.execute(stmt_select)
print("Results:")
for row in cursor.fetchall():
print(row)
cursor.close()
connection.close()
OUTPUT:
Results:
(1, 'USD', '155.48')
(2, 'USD', '149.99')
DESIRED OUTPUT: (something like this)
Results:
('Id', 'Denomination', 'Value')
(1, 'USD', '155.48')
(2, 'USD', '149.99')
Is there any way to get something like that? Thanks for the help.
Currently only the default isolation level is supported. Need to add a parameter to pass in to specify the isolation level upon connection to the database.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.