Unfortunately, that doesn't seem to be the case. I have the database user and password in my settings.py file, but I still have to do a "sudo su postgres" to switch to postgres in the terminal before I can access my PostgreSQL database through the Django database API. Otherwise when I try to access it through my normal username "guillaume", I get:
Traceback (most recent call last): File "<console>", line 1, in <module> File "/usr/local/lib/python2.7/dist-packages/django/db/models/ query.py", line 69, in __repr__ data = list(self[:REPR_OUTPUT_SIZE + 1]) File "/usr/local/lib/python2.7/dist-packages/django/db/models/ query.py", line 84, in __len__ self._result_cache.extend(self._iter) File "/usr/local/lib/python2.7/dist-packages/django/db/models/ query.py", line 273, in iterator for row in compiler.results_iter(): File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/ compiler.py", line 680, in results_iter for rows in self.execute_sql(MULTI): File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/ compiler.py", line 734, in execute_sql cursor = self.connection.cursor() File "/usr/local/lib/python2.7/dist-packages/django/db/backends/ __init__.py", line 250, in cursor cursor = self.make_debug_cursor(self._cursor()) File "/usr/local/lib/python2.7/dist-packages/django/db/backends/ postgresql_psycopg2/base.py", line 140, in _cursor self.connection = Database.connect(**conn_params) OperationalError: FATAL: Peer authentication failed for user "postgres" However, I found a way around the "out" file issue I mentioned earlier; I did a search for my yaml file and changed the write permission on it to all users, so I was then able to access it while in the API under the postgres username. After I did so and attempted to write serialized data to it, I got the following error: >>> yaml_serializer.serialize(Player.objects.all(),stream=out) Traceback (most recent call last): File "<console>", line 1, in <module> File "/usr/local/lib/python2.7/dist-packages/django/core/serializers/ base.py", line 55, in serialize return self.getvalue() File "/usr/local/lib/python2.7/dist-packages/django/core/serializers/ pyyaml.py", line 44, in getvalue return self.stream.getvalue() AttributeError: 'file' object has no attribute 'getvalue' It does seem to have written to the yaml output file. In that, I got: - fields: {age: 25, ast: 1, blk: 2, drb: 17, fg: 7, fga: 16, first_name: Jeff, ft: 7, fta: 12, gp: 8, last_name: Adrien, mp: 63, orb: 5, pf: 13, pos: SF, pts: 21, stl: 0, team: 1, three_pointers: 0, threes_attempted: 0, tov: 2} model: players.player pk: 1 But now I'm wondering what the error the API kicked was about...anyone know? thanks, Guillaume On Feb 17, 7:50 am, Bill Freeman <ke1g...@gmail.com> wrote: > The database user and *nix user are (typically) unrelated. The > database user is specified in settings.py and there is also a password > if necessary. Since one usually communicates with database servers > using network connections (even on the same box), it doesn't really > know what user a connection came from. > > Unless you are using sqlite3 as your database, in which case you just > need to copy and change the ownership of the database file (may > require sudo). > > On 2/16/12, Gchorn <guillaumech...@gmail.com> wrote: > > > > > > > > > Thanks very much for the reply. I went ahead and created a model > > instance using the API, and then tried to get a yaml dump of this. > > However, I'm running into another (newb) problem. The database I'm > > using is under a different username (I'm doing all of this in Ubuntu > > Linux 11.10), which I understood to be good practice. However, when I > > do a python manage.py shell I have to already be in one user name or > > another. The database username gives me access to the database > > through the API, but then I can't create a data dump file because I > > don't have file write access under that username. I can't be under > > both usernames at once can I? Do I just need to give write-access to > > the database username as well? If so how do I do that (I know we're > > veering away from Django here, sorry)? > > > On Feb 17, 1:13 am, Bill Freeman <ke1g...@gmail.com> wrote: > >> Well, I don't know yaml, but if you are in a place where you don't > >> have to quote: > > >> Arron > > >> then I'd expect everything to be strings. > > >> Is there a yaml.dump that you can apply to a model with strings and > >> integers to see how it thinks they are distinguished? > > >> On 2/16/12, Gchorn <guillaumech...@gmail.com> wrote: > > >> > Hello All, > > >> > I'm attempting to provide initial data for my database using a fixture > >> > file (like this: > >> >https://docs.djangoproject.com/en/1.3/howto/initial-data/#providing-i...), > >> > but I'm running into the following error: > > >> > Problem installing fixture '/home/guillaume/NBA/players/fixtures/ > >> > player_data.yaml': Traceback (most recent call last): > >> > File "/usr/local/lib/python2.7/dist-packages/django/core/management/ > >> > commands/loaddata.py", line 169, in handle > >> > for obj in objects: > >> > File "/usr/local/lib/python2.7/dist-packages/django/core/serializers/ > >> > pyyaml.py", line 54, in Deserializer > >> > for obj in PythonDeserializer(yaml.load(stream), **options): > >> > File "/usr/local/lib/python2.7/dist-packages/django/core/serializers/ > >> > python.py", line 122, in Deserializer > >> > data[field.attname] = > >> > field.rel.to._meta.get_field(field.rel.field_name).to_python(field_value) > >> > File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/ > >> > __init__.py", line 471, in to_python > >> > raise exceptions.ValidationError(self.error_messages['invalid']) > >> > ValidationError: [u'This value must be an integer.'] > > >> > Here is a sample from the YAML fixture file I'm attempting to use: > > >> > - model: players.player > >> > pk: 2 > >> > fields: > >> > team: DEN > >> > first_name: Arron > >> > last_name: Afflalo > >> > age: 26 > >> > pos: SG > >> > gp: 25 > >> > mp: 754 > >> > fg: 98 > >> > fga: 227 > >> > ft: 62 > >> > fta: 78 > >> > three_pointers: 31 > >> > threes_attempted: 81 > >> > orb: 15 > >> > drb: 51 > >> > ast: 39 > >> > stl: 15 > >> > blk: 6 > >> > tov: 33 > >> > pf: 55 > >> > pts: 289 > > >> > Isn't what I have there mostly integers? I've already checked my > >> > models.py file to make sure I didn't accidentally use an > >> > "IntegerField" for "team", "first_name", "last_name", or "pos." Do I > >> > need to include some other kind of formatting information in my YAML > >> > file to indicate that the numbers are integers? > > >> > thanks, > >> > Guillaume > > >> > -- > >> > You received this message because you are subscribed to the Google > >> > Groups > >> > "Django users" group. > >> > To post to this group, send email to django-users@googlegroups.com. > >> > To unsubscribe from this group, send email to > >> > django-users+unsubscr...@googlegroups.com. > >> > For more options, visit this group at > >> >http://groups.google.com/group/django-users?hl=en. > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-users@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com. > > For more options, visit this group at > >http://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.