summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rwxr-xr-xxboomx/bin/xboomx_python2mirgation.py49
2 files changed, 49 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index 51cbe85..03b2136 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,7 +8,6 @@ __pycache__/
# Distribution / packaging
.Python
env/
-bin/
build/
develop-eggs/
dist/
diff --git a/xboomx/bin/xboomx_python2mirgation.py b/xboomx/bin/xboomx_python2mirgation.py
new file mode 100755
index 0000000..cc38c7d
--- /dev/null
+++ b/xboomx/bin/xboomx_python2mirgation.py
@@ -0,0 +1,49 @@
+#!/usr/bin/env python2
+# coding=utf-8
+import os
+from pprint import pprint
+from sqlalchemy import create_engine
+from sqlalchemy.ext.declarative import declarative_base
+from sqlalchemy.orm import sessionmaker
+
+__author__ = 'Victor Häggqvist'
+
+import shelve
+
+dbname = 'xboomx.db'
+shelvepath = os.path.join(os.getenv("HOME"), '.xboomx', dbname)
+db = shelve.open(shelvepath)
+pprint(db)
+
+
+dbname = 'xboomx_sqlite.db'
+dbpath = os.path.join(os.getenv("HOME"), '.xboomx', dbname)
+dsn = 'sqlite:///%s' % dbpath
+
+engine = create_engine(dsn, echo=True)
+Base = declarative_base()
+
+from sqlalchemy import Column, Integer, String
+
+
+class PathItem(Base):
+ __tablename__ = 'pathitems'
+ id = Column(Integer, primary_key=True)
+ name = Column(String)
+ count = Column(Integer)
+
+ def __repr__(self):
+ return "<PathItem(name='%s', count='%s')>" % (self.name, self.count)
+
+
+Base.metadata.create_all(engine)
+Session = sessionmaker(bind=engine)
+session = Session()
+
+for dbi in db:
+ print('migrating %s: %s' % (dbi, db[dbi]))
+ sqlitem = PathItem(name=dbi, count=db[dbi])
+ session.add(sqlitem)
+
+session.commit()
+print('migration done')