Last active
September 27, 2017 07:38
-
-
Save LarryStanley/aca4f6d2f41b4a8226e6cbe83adbeeb4 to your computer and use it in GitHub Desktop.
etc-python-sqlite
This file contains 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
from sqlite import Gp2014 | |
from tqdm import tqdm | |
if __name__ == '__main__': | |
gp = Gp2014.select().limit(20) | |
for row in gp: | |
print(row.gantryfrom) #取得出發點 | |
print(row.gantryto) #取得終點 | |
print(row.vehicletype) #取得車種 |
This file contains 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
from peewee import * | |
database = SqliteDatabase('2014_with_index.sqlite', **{}) | |
class UnknownField(object): | |
def __init__(self, *_, **__): pass | |
class BaseModel(Model): | |
class Meta: | |
database = database | |
class GantryP(BaseModel): | |
d1 = UnknownField(null=True) # | |
d2 = UnknownField(null=True) # | |
gantryfrom = TextField(null=True) | |
gantryto = TextField(null=True) | |
num = UnknownField(null=True) # | |
class Meta: | |
db_table = 'gantry_p' | |
class Gp2014(BaseModel): | |
gantryfrom = TextField(db_column='GantryFrom', null=True) | |
gantryto = TextField(db_column='GantryTo', null=True) | |
spacemeanspeed = FloatField(db_column='SpaceMeanSpeed', null=True) | |
timeinterval = TextField(db_column='TimeInterval', null=True) | |
trafficvolume = IntegerField(db_column='TrafficVolume', null=True) | |
traveltime = IntegerField(db_column='TravelTime', null=True) | |
vehicletype = IntegerField(db_column='VehicleType', null=True) | |
julian = FloatField(null=True) | |
class Meta: | |
primary_key = False | |
db_table = 'gp_2014' | |
indexes = ( | |
(('gantryfrom', 'gantryto', 'julian', 'vehicletype', 'timeinterval', 'trafficvolume', 'traveltime', 'spacemeanspeed'), False), | |
(('julian', 'vehicletype', 'gantryfrom', 'gantryto', 'timeinterval', 'trafficvolume', 'traveltime', 'spacemeanspeed'), False), | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment