Skip to content

Commit

Permalink
setup script + doc improvement + tsv exporter
Browse files Browse the repository at this point in the history
  • Loading branch information
ogrisel committed May 3, 2012
1 parent 02f1d26 commit b8b5c1d
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 5 deletions.
9 changes: 8 additions & 1 deletion dbpediakit/postgres.py
Expand Up @@ -169,5 +169,12 @@ def check_text_table(archive_name, table, database=DATABASE, **extract_params):
copy(tuples, table, database=database) copy(tuples, table, database=database)
logging.info("Creating index on column '%s' in table '%s'", logging.info("Creating index on column '%s' in table '%s'",
"id", table) "id", table)
execute(CREATE_INDEX.format(table=table, column="id")) execute(CREATE_INDEX.format(table=table, column="id"), database=database)
return True 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)
6 changes: 2 additions & 4 deletions examples/topics/README.md
Expand Up @@ -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 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`: user and your dbpediakit usage. For instance my unix account is `ogrisel`:


$ sudo su - postgres $ sudo -u postgres createuser ogrisel
$ createuser ogrisel
Shall the new role be a superuser? (y/n) y Shall the new role be a superuser? (y/n) y
$ createdb -O ogrisel -E UTF8 dbpediakit $ sudo -u postgres createdb -O ogrisel -E UTF8 dbpediakit
$ ^D


You can check that database dbpediakit has been created successfully and that You can check that database dbpediakit has been created successfully and that
your unix account as access to it with:: your unix account as access to it with::
Expand Down
38 changes: 38 additions & 0 deletions setup.py
@@ -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.