Re: python and post gis question
Τη Παρασκευή, 16 Ιουνίου 2017 - 10:59:10 μ.μ. UTC+3, ο χρήστης Xristos Xristoou
έγραψε:
> I have create a python script where use post gis queries to automate some
> intersection tasks using postgis database.
>
> in my database I have polygons,points and lines.
>
> here my snippet code of my script :
>
> try:
> if str(geomtype) == 'point':
> geomtype = 1
> elif str(geomtype) == 'linestring':
> geomtype = 2
> elif str(geomtype) == 'polygon':
> geomtype = 3
> else:
> raise TypeError()
> sql = "\nDROP TABLE IF EXISTS {0}.{1};\nCREATE TABLE {0}.{1} AS (SELECT
> {4},\n(st_dump(ST_CollectionExtract(st_intersection(dbgis.{2}.shape,dbgis.{3}.shape)::GEOMETRY(GEOMETRY,2345),{5}))).geom
> AS shape\nFROM dbgis.{2}, dbgis.{3} WHERE
> st_intersects(dbgis.{2}.shape,dbgis.{3}.shape) AND {5}=3);\nCREATE INDEX
> idx_{2}_{3}_{6} ON {0}.{1} USING GIST (shape);\nALTER TABLE {0}.{1} ADD
> COLUMN id SERIAL;\nALTER TABLE {0}.{1} ADD COLUMN my_area double
> precision;\nUPDATE {0}.{1} SET my_area = ST_AREA(shape::GEOMETRY);\nALTER
> TABLE {0}.{1} ADD PRIMARY KEY (id);\nSELECT
> pop_g_col('{0}.{1}'::REGCLASS);\nGRANT ALL ON {0}.{1} TO GROUP u_cl;\nGRANT
> ALL ON {0}.{1} TO GROUP my_user;\n-- VACUUM ANALYZE
> {0}.{1};\n".format(schema, table, tablea, tableb, selects, geomtype, id_gen())
> return sql
> this post gis sql query work nice but I need the new field where I want to
> add my_area to create only for polygons layers.
>
> that code create for all layers (lines,points,polygons) that field my_area if
> layer is point or line then take value 0 I don't like that I don't need it.
>
> how to change this code to create my_area only in polygons ?
i wabt to ccreate a new field only in polygons layera
--
https://mail.python.org/mailman/listinfo/python-list
json to access using python
hello I have a json url and i want from this url to update my table in microsoft access,how to do that using python or some tool of microsoft access ? -- https://mail.python.org/mailman/listinfo/python-list
Reciprocal data structures
I'm not sure if "reciprocal" is the right word, or if there is an official term for this. I am thinking of a list that actively maintains in its items a member that contains the item's own index in the list. Basically, the item knows its index into the list and the list ensures that the index remains in sync. If the list is changed, the list updates the indices. This is a the that might be useful in implementing observer pattern. I guess I am questioning if there's a well-known package that does anything like this? I don't know what the official computer science term might be for this so I'm having trouble googling for it. I don't need this kind of thing a lot, but to me it has the feel of something that should be already available somewhere. Carl Banks -- https://mail.python.org/mailman/listinfo/python-list
Re: json to access using python
On Sunday, June 18, 2017 at 7:50:10 PM UTC+1, Xristos Xristoou wrote: > hello > > > I have a json url and i want from this url to update my table in microsoft > access,how to do that using python or some tool of microsoft access ? You need to do some research first. Then you run an editor and type some code in. Then you run the code. If it does not work and you do not understand why you then ask a question here. You might like to reference this http://www.catb.org/esr/faqs/smart-questions.html and this http://sscce.org/ first. Kindest regards. Mark Lawrence. -- https://mail.python.org/mailman/listinfo/python-list
Re: Reciprocal data structures
On Mon, Jun 19, 2017 at 5:27 AM, wrote: > I am thinking of a list that actively maintains in its items a member that > contains the item's own index in the list. Basically, the item knows its > index into the list and the list ensures that the index remains in sync. If > the list is changed, the list updates the indices. This is a the that might > be useful in implementing observer pattern. > With a list? No, I would say it's a bad idea. But with a dictionary, you certainly can. Consider something that loads up something based on its unique ID (which could be a number or a string or something), and then the thing itself has that ID. Very common in databasing, for instance. You can then have a lookup dictionary where you grab them from your cache, and the objects themselves have a "foo.id" attribute. The IDs are immutable and eternal, unlike list indices, and they are truly a feature of the object, so this makes a lot of sense. And it's something I've done reasonably often. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: json to access using python
On 18/06/2017 20:34, [email protected] wrote: On Sunday, June 18, 2017 at 7:50:10 PM UTC+1, Xristos Xristoou wrote: hello I have a json url and i want from this url to update my table in microsoft access,how to do that using python or some tool of microsoft access ? You need to do some research first. Then you run an editor and type some code in. Then you run the code. If it does not work and you do not understand why you then ask a question here. You might like to reference this http://www.catb.org/esr/faqs/smart-questions.html and this http://sscce.org/ first. Kindest regards. Mark Lawrence. Mark, I thought this guy was nymshift of Ferrous Cranium or whatever he was called. -- https://mail.python.org/mailman/listinfo/python-list
Re: Progress on the Gilectomy
I always thought the GIL removal obstacle was the need to put locks around every refcount adjustment, and the only real cure for that is to use a tracing GC. That is a good idea in many ways, but it would break the existing C API quite seriously. Reworking the C modules in the stdlib would be a large but not impossible undertaking. The many external C modules out there would be more of an issue. -- https://mail.python.org/mailman/listinfo/python-list
Error while connecting Teradata
Hi All ,
I am getting below Error while connecting Teradata using Python:
- File "C:\Python27\Lib\site-packages\teradata\udaexec.py", line 183, in
connect
**args))
File "C:\Python27\Lib\site-packages\teradata\tdodbc.py", line 427, in
__init__
connectParams["DRIVER"] = determineDriver(dbType, driver)
File "C:\Python27\Lib\site-packages\teradata\tdodbc.py", line 391, in
determineDriver
"Available drivers: {}".format(dbType, ",".join(drivers)))
InterfaceError: ('DRIVER_NOT_FOUND', "No driver found for 'Teradata'
I am using below code to connect :
- import teradata
udaExec = teradata.UdaExec (appName="HelloWorld", version="1.0",
logConsole=False)
session = udaExec.connect(method="odbc", system="tdpr101",
username="xxx", password="xxx");
Could anyone please let me know how to resolve this Error.
Thanks,
Mradul
--
https://mail.python.org/mailman/listinfo/python-list
Re: Instagram: 40% Py3 to 99% Py3 in 10 months
Paul Barry writes: > The process they followed is discussed in their recent Keynote at PyCon > 2017: https://youtu.be/66XoCk79kjM > Well worth the 40 minutes it takes to watch :-) If it takes 40 minutes to describe how they did it, that sounds like more hassle than most users of working py2 code probably want to deal with. -- https://mail.python.org/mailman/listinfo/python-list
Re: Instagram: 40% Py3 to 99% Py3 in 10 months
On Sun, 18 Jun 2017 20:57:56 -0700, Paul Rubin wrote: > Paul Barry writes: >> The process they followed is discussed in their recent Keynote at PyCon >> 2017: https://youtu.be/66XoCk79kjM Well worth the 40 minutes it takes >> to watch :-) > > If it takes 40 minutes to describe how they did it, that sounds like > more hassle than most users of working py2 code probably want to deal > with. Well that depends on whether you have 100 lines of code or 100 million lines of code. One of the guys in my office migrated the Python code base for one of our internal projects overnight. The cheeky bugger didn't even tell us he was going to do it, he just stayed in the office one night for an extra three or four hours and presented us with a fait-accompli the next day. Admittedly it wasn't a huge code base, by memory something like twenty scripts and modules and 5-10 KLOC, give or take. That's not bad. I've spent an hour just formatting the comments in a single module *wink* -- Steve -- https://mail.python.org/mailman/listinfo/python-list
Re: Reciprocal data structures
On Mon, 19 Jun 2017 06:04:57 +1000, Chris Angelico wrote: > On Mon, Jun 19, 2017 at 5:27 AM, wrote: >> I am thinking of a list that actively maintains in its items a member >> that contains the item's own index in the list. Basically, the item >> knows its index into the list and the list ensures that the index >> remains in sync. If the list is changed, the list updates the indices. >> This is a the that might be useful in implementing observer pattern. How would you use this? Can you give some demonstration pseudo-code? > With a list? No, I would say it's a bad idea. Why a bad idea? As opposed to "can't be done", or "too hard and slow". > But with a dictionary, you > certainly can. Consider something that loads up something based on its > unique ID (which could be a number or a string or something), and then > the thing itself has that ID. Very common in databasing, for instance. > You can then have a lookup dictionary where you grab them from your > cache, and the objects themselves have a "foo.id" attribute. > The IDs are immutable and eternal, unlike list indices, and they are > truly a feature of the object, so this makes a lot of sense. And it's > something I've done reasonably often. -- Steve -- https://mail.python.org/mailman/listinfo/python-list
Re: Reciprocal data structures
On Mon, Jun 19, 2017 at 3:54 PM, Steven D'Aprano wrote: >> With a list? No, I would say it's a bad idea. > > > Why a bad idea? > > As opposed to "can't be done", or "too hard and slow". Maintaining a record of list indices inside an object, with the specific proviso that: > If the list is changed, the list updates the indices. ? I think it's a bad idea because it's trying to use a changeable position as an attribute of an object. It seems like a job that's much better done with an immutable identifier. I might do it as the OP suggested *if* the IDs are never reused or deleted (or if you delete by replacing the object with None or something), which would make indices effectively immutable. But the idea that you should have list mutations that have to go and update everything else? Perilous. You're opening yourself up for a ton of tiny bugs. Of course, if the OP is a perfect programmer who never makes a single mistake, then sure, go ahead - it's not impossible - but I don't like the idea that you can do a mutation that works, but leaves things in a subtly inconsistent state, so the next operation (looking up an object) also works, but the one *after that* doesn't. It also means that you can't snapshot an ID to use as a reference, but can only use them *right now* (eg in a method on that object), which limits their usability. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
