Permalink
Browse files

setup script + doc improvement + tsv exporter

  • Loading branch information...
ogrisel committed May 3, 2012
1 parent 02f1d26 commit b8b5c1dfc8a0b75d260a7ee1dc011c9fb73cb595
Showing with 48 additions and 5 deletions.
  1. +8 −1 dbpediakit/postgres.py
  2. +2 −4 examples/topics/README.md
  3. +38 −0 setup.py
View
@@ -169,5 +169,12 @@ def check_text_table(archive_name, table, database=DATABASE, **extract_params):
copy(tuples, table, database=database)
logging.info("Creating index on column '%s' in table '%s'",
"id", table)
- execute(CREATE_INDEX.format(table=table, column="id"))
+ execute(CREATE_INDEX.format(table=table, column="id"), database=database)
return True
+
+
+def export_as_tsv(table, columns, filename, database=DATABASE):
+ """Export the content of a SQL table as tab separated values file"""
+ sql = "copy (select %s from %s) TO '%s';" % (
+ ', '.join(columns), table, filename)
+ execute(sql, database=database)
@@ -20,11 +20,9 @@ To initialize the PostgreSQL under Ubuntu / Debian::
Then switch to the postgres admin user to create a role and DB for your unix
user and your dbpediakit usage. For instance my unix account is `ogrisel`:
- $ sudo su - postgres
- $ createuser ogrisel
+ $ sudo -u postgres createuser ogrisel
Shall the new role be a superuser? (y/n) y
- $ createdb -O ogrisel -E UTF8 dbpediakit
- $ ^D
+ $ sudo -u postgres createdb -O ogrisel -E UTF8 dbpediakit
You can check that database dbpediakit has been created successfully and that
your unix account as access to it with::
View
@@ -0,0 +1,38 @@
+#! /usr/bin/env python
+
+DISTNAME = 'dbpediakit'
+DESCRIPTION = """Python / SQL utilities to work with the DBpedia dumps"""
+LONG_DESCRIPTION = open('README.md').read()
+MAINTAINER = 'Olivier Grisel'
+MAINTAINER_EMAIL = 'olivier.grisel@ensta.org'
+URL = 'https://github.com/ogrisel/dbpediakit'
+LICENSE = 'MIT'
+VERSION = '0.1-git'
+
+from distutils.core import setup
+
+
+if __name__ == "__main__":
+
+ setup(name=DISTNAME,
+ maintainer=MAINTAINER,
+ maintainer_email=MAINTAINER_EMAIL,
+ description=DESCRIPTION,
+ license=LICENSE,
+ url=URL,
+ version=VERSION,
+ long_description=LONG_DESCRIPTION,
+ classifiers=[
+ 'Intended Audience :: Science/Research',
+ 'Intended Audience :: Developers',
+ 'License :: OSI Approved',
+ 'Programming Language :: Python',
+ 'Programming Language :: SQL',
+ 'Topic :: Software Development',
+ 'Topic :: Scientific/Engineering',
+ 'Operating System :: Microsoft :: Windows',
+ 'Operating System :: POSIX',
+ 'Operating System :: Unix',
+ 'Operating System :: MacOS'
+ ]
+ )

0 comments on commit b8b5c1d

Please sign in to comment.