Created
May 4, 2018 06:48
-
-
Save chaudum/4a4df482c1b025369aaa34e82215936f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import sys | |
from datetime import datetime | |
from crate.client import connect | |
def main(): | |
now = datetime.utcnow() | |
with connect('localhost:4200') as conn: | |
cur = conn.cursor() | |
cur.execute('CREATE TABLE IF NOT EXISTS t2 (col_str STRING, col_long LONG, col_ts TIMESTAMP)') | |
cur.execute('INSERT INTO t2 (col_str, col_long, col_ts) VALUES (?, ?, ?)', | |
(now, now, now)) | |
cur.execute('REFRESH TABLE t2') | |
cur.execute('SELECT col_str, col_long, col_ts FROM t2') | |
cols = [c[0] for c in cur.description] | |
for idx, val in enumerate(cur.fetchone()): | |
print('{} => {} ({})'.format(cols[idx], val,type(val))) | |
if __name__ == '__main__': | |
sys.exit(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment