SHARE
TWEET

Sample Code

Uno-Dan Jun 29th, 2020 1,159 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     t = DTree(unique=False)
  2.     sql = f'SELECT id, name FROM country WHERE code2="CA" ORDER BY name;'
  3.     if app.db.execute(sql):
  4.         for country_row in app.db.fetchall():
  5.             country_id, name = country_row
  6.             country_node = Node(name=name.strip(), parent=t)
  7.  
  8.             sql = f'SELECT id, name FROM country_zone WHERE country_id=%s ORDER BY name;'
  9.             if app.db.execute(sql, (country_id, )):
  10.                 for zone_row in app.db.fetchall():
  11.                     zone_id, name = zone_row
  12.                     zone_node = Node(name=name.strip(), parent=country_node)
  13.  
  14.                     sql = f'SELECT id, name FROM country_place WHERE zone_id=%s ORDER BY name;'
  15.                     if app.db.execute(sql, (zone_id, )):
  16.                         for place_row in app.db.fetchall():
  17.                             place_id, name = place_row
  18.                             Leaf(name=name.strip(), parent=zone_node)
  19.  
  20.         t.query('Canada/Ontario').show()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top