if __name__== '__main__': from OpenElectrophy import open_db, sql, neo_to_oe, TryItIO import datetime import numpy # connection to a DB open_db( url = 'sqlite:///test.sqlite', myglobals= globals(), use_global_session = True) # create 5 Blocks with different dates for i in range(5): neo_bl = TryItIO().read(nb_segment = 2, duration = 2) bl = neo_to_oe(neo_bl, cascade = True) bl.rec_datetime = datetime.datetime(2012, 06, 1+i, 12,30,40) bl.name = 'test sql %d' %i bl.save() print bl # select all Block.id after 3 june 2012 and Segment name is 1 query = """ SELECT Block.id, Segment.id, AnalogSignal.id FROM Block, Segment, AnalogSignal WHERE Block.id = Segment.block_id AND Segment.id = AnalogSignal.segment_id AND Block.rec_datetime > '2012-06-03'
from OpenElectrophy import open_db, neo_to_oe # connection to a DB open_db(url='sqlite:///test.sqlite', myglobals=globals(), use_global_session=True) import neo import urllib.request, urllib.parse, urllib.error # Plexon files distantfile = 'https://portal.g-node.org/neo/plexon/File_plexon_3.plx' localfile = './File_plexon_3.plx' urllib.request.urlretrieve(distantfile, localfile) #create a reader reader = neo.io.PlexonIO(filename='File_plexon_3.plx') # read the block neo_bl = reader.read(cascade=True, lazy=False)[0] #transform to mapped class oe_bl = neo_to_oe(neo_bl, cascade=True) oe_bl.save() bl_id = oe_bl.id #open again, load and transform to neo open_db(url='sqlite:///test.sqlite', myglobals=globals(), use_global_session=True) oe_bl2 = Block(id=bl_id) print(type(oe_bl2)) noe_bl2 = oe_bl2.to_neo(cascade=True) print(type(noe_bl2))