how to set PostGIS as a datasource?

Hi there, I am following tutorials to learn about OSM and how to make some maps. Currently I am using this one, but in the instructions it uses shapefiles as a datasource just in a normal file directory. I don’t want to do that, I want the file source to be from my database in PostGIS, where I have stored my OSM data. What do I need to do to make it do that? I tried:

lyr = Layer(‘Geometry from PostGIS’) lyr.datasource = PostGIS(host=‘localhost’,user=‘postgres’,password=‘’,dbname=‘your_postgis_database’,table=‘your_table’)

which I copied off one of the wiki pages. Obviously I amended details as appropriate, but it just said layer not recognised. I wondered if there way something I had to do or tell it to do to get into the database?

In the literature I have read, it says that using PostGIS is one of the most common ways of doing what I want to do, but I cannot seem to find any code to use! Thanks in Advance, Tracey