tk0miya / testing.postgresql

Apache License 2.0
290 stars 46 forks source link

What data format does copy_data_from expect? #1

Closed jimfulton closed 9 years ago

jimfulton commented 9 years ago

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'
tk0miya commented 9 years ago

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()
jimfulton commented 9 years ago

Thanks.

fuzzyami commented 5 years ago

should prolly go into the readme.