<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<atom:link href="http://dev1galaxy.org/extern.php?action=feed&amp;tid=6164&amp;type=rss" rel="self" type="application/rss+xml" />
		<title><![CDATA[Dev1 Galaxy Forum / sqlalchemy]]></title>
		<link>http://dev1galaxy.org/viewtopic.php?id=6164</link>
		<description><![CDATA[The most recent posts in sqlalchemy.]]></description>
		<lastBuildDate>Wed, 29 Nov 2023 16:14:22 +0000</lastBuildDate>
		<generator>FluxBB</generator>
		<item>
			<title><![CDATA[Re: sqlalchemy]]></title>
			<link>http://dev1galaxy.org/viewtopic.php?pid=45777#p45777</link>
			<description><![CDATA[<p>It seems that i can make sqlalchemy fetch some data from tables when the connectionstrings are right. <br />But another thing i noticed, with a new vm, docker-compose can&#039;t find the .yml-file with -f. I have to say it&#039;s absolute path, then d-c finds it. <br />Any ideas why? And how to fix that? I ask here, in the case this is a Devuan-specific problem. (Almost 20 years there were some kind of a RedHat-related problem with package gcc, that other distros did&#039;nt have.)</p><p>Something may have gone wrong with thet new vm&#039;s install. Or there is some important package missing. I noticed also that in the new vm&#039;s xfce terminal, there is no colours with output of &quot;ls&quot;.</p><p> That&#039;s not weird when using root-account. But using a normal user account...</p>]]></description>
			<author><![CDATA[dummy@example.com (nahkhiirmees)]]></author>
			<pubDate>Wed, 29 Nov 2023 16:14:22 +0000</pubDate>
			<guid>http://dev1galaxy.org/viewtopic.php?pid=45777#p45777</guid>
		</item>
		<item>
			<title><![CDATA[Re: sqlalchemy]]></title>
			<link>http://dev1galaxy.org/viewtopic.php?pid=45632#p45632</link>
			<description><![CDATA[<p>Managed to get rid of some complaints by changing &quot;c.id_field==&quot; to &quot;c.columns.id_field==&quot;. <br />Maybe the software doesn&#039;t correspond to documentation or another way round.<br />Have to re-check that db-container works as it is supposed to. Tried with psql and got some errors.</p>]]></description>
			<author><![CDATA[dummy@example.com (nahkhiirmees)]]></author>
			<pubDate>Sat, 25 Nov 2023 21:04:58 +0000</pubDate>
			<guid>http://dev1galaxy.org/viewtopic.php?pid=45632#p45632</guid>
		</item>
		<item>
			<title><![CDATA[Re: sqlalchemy]]></title>
			<link>http://dev1galaxy.org/viewtopic.php?pid=45601#p45601</link>
			<description><![CDATA[<p>Maybe stackexchange.com would be a better place for this topic. But i don&#039;t have account on that site.</p><p>Anyways, changed logging settings in postgres-container. I started getting &quot;LOG connection authetticated&quot;-messages. <br />Entered into running python container with docker exec, started Python interpreter and started entering commands. Those &quot;authenticated&quot;-messages arrived into stderr. So now i know that sqlalchemy can connect into&#160; postgres. </p><p>But &quot;r=conn.execute(text(&quot;SELECT * FROM table1&quot;))&quot;, which i tried instead of &quot;c.select().where()&quot; is still a problem. For some reason it doesn&#039;t return any rows. I think it should. <br />And it is very stupid if i have to enter commands that way.&#160; &#160;I thought that with sqlalchemy, another way of doing queries would be possible.</p>]]></description>
			<author><![CDATA[dummy@example.com (nahkhiirmees)]]></author>
			<pubDate>Thu, 23 Nov 2023 17:19:28 +0000</pubDate>
			<guid>http://dev1galaxy.org/viewtopic.php?pid=45601#p45601</guid>
		</item>
		<item>
			<title><![CDATA[Re: sqlalchemy]]></title>
			<link>http://dev1galaxy.org/viewtopic.php?pid=45596#p45596</link>
			<description><![CDATA[<p>Now i think that i have to confirm that postgres gets the sql commands at all. Parameter &quot;echo=True&quot; results in Python echoing the commands sqlalchemy generates. So i know that something happens on the Python-side of things. </p><p>But i&#039;m not sure that those commands end up in postgres-container. So i&#039;ll have to tail -f some_log_file . Postres-container should echo some parts of the commands it receives, into stdout. And i haven&#039;t noticed any from that Flask-container.</p><p>Another thing is commands trying to select from database pg_catalog. I know these are necessary in order to copy pre-existing database structure into code.&#160; <br />The account i use to select from &quot;table1&quot; may not have necessary privileges to use that catalog. Have to do some gogling to find out which are the absolute minimal grants that i need. <br />IMO it is stupid to GRANT ALL PRIVILEGES ON ALL DATABASES just to select from 1 table. </p><p>But anyways, working example code would be very nice to find. <br />It was 2012 when i tried Flask before. I have the previous &quot;hello_world&quot;-attempt printed in paper. But it is half-finished and outdated. And then there is the principal problem that i don&#039;t need to define all the tables in code when i have already built the db, outside the Flask-container. </p><p>P.S. and then there is the question about psycopg2, which version actually works and can i download it from anywhere anymore? And is &quot;no news is good news&quot; still a valid principle?</p>]]></description>
			<author><![CDATA[dummy@example.com (nahkhiirmees)]]></author>
			<pubDate>Thu, 23 Nov 2023 12:47:25 +0000</pubDate>
			<guid>http://dev1galaxy.org/viewtopic.php?pid=45596#p45596</guid>
		</item>
		<item>
			<title><![CDATA[sqlalchemy]]></title>
			<link>http://dev1galaxy.org/viewtopic.php?pid=45581#p45581</link>
			<description><![CDATA[<p>By the way, any Python nerds in this forum? Experienced in sqlalchemy?</p><p>(This is Devuan-related in the sense that the host OS is Devuan Chimaera. Inside and outside the vm. &#039;)</p><p>First time in 10 years i try to write a simple app with Flask and SQLAlchemy. Should be a simple thing, but more the instructions i read, the more confused i become. A three day parade march to Kabul is turning into a 10-year-long-nightmare-in-the-mountains. </p><p>I mean, it should&#039;t bee too difficult to:</p><p>1. set up connection to a pre-existing db<br />2. query a table with user-provided value<br />3. show result back to user somehow</p><p>But i have been running into many kinds of errors today.</p><p>I think setting up the conn works</p><div class="codebox"><pre><code>e=sqlalchemy.create_engine(&lt;A_CONNECTION_STRING&gt;, echo=True)
conn=e.connect()</code></pre></div><p>at least i get no complaints from Flask.<br />I query the table with:</p><div class="codebox"><pre><code>metadata=MetaData()
c=Table(&#039;table1&#039;, metadata, autoload_with=e)
q=c.select().where(c.id_field==user_provided_id)
res=conn.execute(q).fetchone()</code></pre></div><p>... and couldn&#039;t get to phase #3 . There were all kinds of complaints. For example:&quot;AttributeError &#039;Table&#039; object has no attribute &#039;id_field&#039; &quot;. </p><p>I have confirmed, with psql that i can connect to the db with the connectionstring(to be more precise:login, password and other params) i have. Also i have confirmed that&#160; name of the table and column are right. There also should be row with the id value i tried with. </p><p>Any working example code anaywhere which does what i&#039;m looking for? <br /> I mean i have read some of the sqlalchemy docs. Also tried <a href="https://www.datacamp.com/tutorial/sqlalchemy-tutorial-examples" rel="nofollow">https://www.datacamp.com/tutorial/sqlal … l-examples</a> and <a href="https://www.blog.pythonlibrary.org/2010/09/10/sqlalchemy-connecting-to-pre-existing-databases/" rel="nofollow">https://www.blog.pythonlibrary.org/2010 … databases/</a> . To no avail.</p><p>One thing that can complicate simple things is Docker. I use bitnami/python:3.8.17. Tried also bitnami/python:latest. No difference, the Flask app is still not working.</p><p>Nothing surprising in Dockerfile: WORKDIR , COPY requirements.txt into container and RUN pip -r requirements.txt . And outside of Dockerfile, mount the app directory. </p><p>Inside vm, &quot;dpkg -l docker*&quot; says:</p><div class="codebox"><pre><code>ii docker-compose 1.25.0-1
ii docker.io 20.10.5+dfsg10+deb11u2</code></pre></div><p>And requirements.txt pip uses says, amongst other things:</p><div class="codebox"><pre><code>Flask==3.0.0
psycopg2-binary==2.9.9
SQLAlchemy==2.0.22</code></pre></div><p>There were also line: &quot;flask-sqlalchemy==3.1.1&quot;. But i commented that out. To see if something changes. Nope. Not in a way that matters.</p><p>I suspect that those packages installed by pip also complicate a task that should be simple. New version of every package comes out 2 or 3 times a day and no one bothers to check if they work as intended or not. Which versions should work? Should i comment out flask-sqlalchemy or SQLAlchemy? Commenting out both will definitely prevent the db connection. </p><p>Somehow i&#039;m not surprised that SQL injection is still a thing in 2020&#039;ies. It seems that devs are forced to do queries in a very primitive and dangerous way.<br />Also it seems that it is mandatory to use scripting language abominations from the 1990&#039;ies to get anything done at all.</p>]]></description>
			<author><![CDATA[dummy@example.com (nahkhiirmees)]]></author>
			<pubDate>Thu, 23 Nov 2023 01:06:02 +0000</pubDate>
			<guid>http://dev1galaxy.org/viewtopic.php?pid=45581#p45581</guid>
		</item>
	</channel>
</rss>
