tk0miya / testing.postgresql

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What data format does copy_data_from expect?

jimfulton opened this issue · comments

I tried referencing a tablespace directory containing a single database and that failed:

>>> pg = testing.postgresql.Postgresql(copy_data_from='/aledade-test-data')
pg = testing.postgresql.Postgresql(copy_data_from='/aledade-test-data')
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/Users/jim/.buildout/eggs/testing.postgresql-1.2.0-py3.4.egg/testing/postgresql.py", line 69, in __init__
    self.setup()
  File "/Users/jim/.buildout/eggs/testing.postgresql-1.2.0-py3.4.egg/testing/postgresql.py", line 132, in setup
    raise RuntimeError("initdb failed: %r" % err)
RuntimeError: initdb failed: b'initdb: directory "/var/folders/vl/jn0sr3ds7h9b1zs9_lts29s00000gp/T/tmp1n_17su_/data" exists but is not empty\nIf you want to create a new database system, either remove or empty\nthe directory "/var/folders/vl/jn0sr3ds7h9b1zs9_lts29s00000gp/T/tmp1n_17su_/data" or run initdb\nwith an argument other than "/var/folders/vl/jn0sr3ds7h9b1zs9_lts29s00000gp/T/tmp1n_17su_/data".\n'

testing.postgresql expects a directory that is generated by initdb command:

$ initdb -D example -U postgres
$ ls example/
PG_VERSION  global/   pg_hba.conf    pg_multixact/  pg_subtrans/  pg_twophase/  postgresql.conf
base/       pg_clog/  pg_ident.conf  pg_stat_tmp/   pg_tblspc/    pg_xlog/
$ python
>>> import testing.postgresql
>>> pg = testing.postgresql.Postgresql(copy_data_from='example')
>>> pg.stop()

Thanks.

should prolly go into the readme.