jaydebeapi icon indicating copy to clipboard operation
jaydebeapi copied to clipboard

Driver time conversion

Open leedsrising opened this issue 6 years ago • 3 comments

I am using jaydebeapi to extract data from sqlworkbenchj, and was hoping to figure out if there is a way to toggle time zone conversions. I am trying to work with data in UTC, although jaydebeapi is returning data that is in EST - as compared with Prestodb, for example, which keeps time in UTC.

leedsrising avatar Mar 23 '18 18:03 leedsrising

@baztian , @leedsrising I have found that setting JVM arg -Duser.timezone=UTC allows me to get data back in UTC.

From what I can tell jaydebeapi does not currently support the JAVA_OPTS environment variable nor provide a way to pass in specific JVM args.

@baztian Can this be added?

Thank you.

mfulton26 avatar Jul 12 '18 20:07 mfulton26

@leedsrising I did find an alternative. You can take a look at how jaydebeapi starts the JVM and then just start it yourself passing in whatever args you need (e.g. -Duser.timezone=UTC). That's worked for me so far.

mfulton26 avatar Jul 12 '18 22:07 mfulton26

I had the same problem. I edited _jdbc_connect_jpype function and fixed it. See the last line

def _jdbc_connect_jpype(jclassname, url, driver_args, jars, libs):
    import jpype
    if not jpype.isJVMStarted():
        args = []
        class_path = []
        if jars:
            class_path.extend(jars)
        class_path.extend(_get_classpath())
        if class_path:
            args.append('-Djava.class.path=%s' %
                        os.path.pathsep.join(class_path))
        if libs:
            # path to shared libraries
            libs_path = os.path.pathsep.join(libs)
            args.append('-Djava.library.path=%s' % libs_path)
        args.append('-Duser.timezone=GMT') # ADD THIS LINE TO CODE

evyasonov avatar Dec 20 '18 14:12 evyasonov