You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			63 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			HTML
		
	
			
		
		
	
	
			63 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			HTML
		
	
 | 
						|
<script>
 | 
						|
  async function ToClipboard(text) {
 | 
						|
    try {
 | 
						|
      await navigator.clipboard.writeText(text);
 | 
						|
      console.log('Text copied to clipboard successfully!');
 | 
						|
    } catch (err) {
 | 
						|
      console.error('Failed to copy text:', err);
 | 
						|
    }
 | 
						|
  }  
 | 
						|
  var copy = function(){
 | 
						|
    _i = $('<i class="fa-solid fa-check"></i>')
 | 
						|
    _button = $('.generated-code .copy')
 | 
						|
    $(_button).empty()
 | 
						|
    $(_button).append(_i)
 | 
						|
    var _code = $('.generated-code code').text()
 | 
						|
    
 | 
						|
    ToClipboard(_code)
 | 
						|
  }
 | 
						|
  $(document).ready(()=>{
 | 
						|
    var _element = $('.generated-code code')[0]
 | 
						|
    _html = $('.generated-code code').html()
 | 
						|
    _html = _html.replace(/:label/g,sessionStorage._label)
 | 
						|
    if (sessionStorage._query.startsWith('{')){
 | 
						|
      pass
 | 
						|
    }else{
 | 
						|
      _html  = _html.replace(/:_query/,`{'sql':"""${sessionStorage._query.replace(/\n/g,' ')}"""}`)
 | 
						|
    }
 | 
						|
    $('.generated-code code').html(_html)
 | 
						|
 | 
						|
    Prism.highlightElement(_element)
 | 
						|
    $('.generated-code .copy').on('click',copy)
 | 
						|
  })
 | 
						|
</script>
 | 
						|
 | 
						|
<div style="width:650px;">
 | 
						|
 | 
						|
<div class="generated-code border-round" style="padding:8px;  background-color: #f3f3f3;">
 | 
						|
  <span class="active copy" style="float:right; padding:4px" >
 | 
						|
    <i class="fa-solid fa-copy" ></i>
 | 
						|
  </span>
 | 
						|
  <pre style="margin:4px; padding:4px;">
 | 
						|
    <code class="code language-python" style="line-height:1.5;text-wrap: wrap;">
 | 
						|
"""
 | 
						|
install data-transport
 | 
						|
pip install data-transport[all]@git+https://github.com/lnyemba/data-transport
 | 
						|
"""
 | 
						|
import transport
 | 
						|
import pandas as pd
 | 
						|
 | 
						|
# data-transport instance to read data
 | 
						|
#
 | 
						|
reader = transport.get.reader(label=':label')
 | 
						|
_args = :_query
 | 
						|
 | 
						|
# reading the query from ":label" into a pandas data-frame
 | 
						|
_df = reader.read(**_args)
 | 
						|
 | 
						|
print(_df.head())
 | 
						|
    </code>
 | 
						|
  </pre>
 | 
						|
</div>
 | 
						|
</div> |