-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdbfscratch.py
More file actions
executable file
·53 lines (37 loc) · 1.39 KB
/
dbfscratch.py
File metadata and controls
executable file
·53 lines (37 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/python
from simpledbf import Dbf5
from sqlalchemy import create_engine
from sqlalchemy import Table
from sqlalchemy import select
from sqlalchemy import MetaData
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
dbf = Dbf5('LIQCODE.dbf', codec='latin-1')
dbf.mem(chunksize=1000)
dbf = dbf.to_pandassql('sqlite:///barcodes.db', if_exists='replace')
dbf2 = Dbf5('BARCODES.dbf', codec='latin-1')
dbf2.mem(chunksize=1000)
dbf2 = dbf2.to_pandassql('sqlite:///barcodes.db', if_exists='replace')
eng = create_engine('sqlite:///barcodes.db')
conn = eng.connect()
meta = MetaData(eng, reflect=True)
liqcode = Table('LIQCODE', meta, autoload=True)
barcode = Table('BARCODES', meta, autoload=True)
select_st = select([liqcode.c.CODE_NUM, liqcode.c.BARCODE, liqcode.c.BARCODE2, liqcode.c.BRAND, liqcode.c.DESCRIP, liqcode.c.TYPE, liqcode.c.SIZE, liqcode.c.PRICE, liqcode.c.STD_QTY, liqcode.c.DEPOSIT]).where(liqcode.c.CODE_NUM == '9237')
res = conn.execute(select_st)
for row in res: print(row)
'''
for c in liqcode.columns:
print c.name
for c in barcode.columns:
print c.name
'''
'''
select_st = select([table]).where(table.c.CODE_NUM == '9237')
res = conn.execute(select_st)
for _row in res: print(_row)
print(Base._decl_class_registry.values())
for c in Base._decl_class_registry.values():
if hasattr(c, '__tablename__') and c.__tablename__ == 'LIQCODE':
print c
'''