Saving record to rails database from python script
<p>I have Rails application with classic forum models like <code>Post</code>, <code>Topic</code>.
Then I have python script using <code>praw</code> to download certain posts and topics from Reddit. (I know that I can use ruby version, but lets say we have to use this python script)</p>

<p>I'd like to put them directly into my rails database.
I can save them in json format and create rake task to upload them into my database, but I think I don't need to add this complexity and should somehowe save them directly to my rails db from this python script.</p>

<p>How can I do this?</p>

<p>So you can use this one:</p>

<pre><code>import psycopg2

db_uri = "dbname='template1' user='dbuser' host='localhost' password='dbpass'"
with psycopg2.connect(db_uri) as conn:
    cur = conn.cursor()
    cur.execute("""SELECT datname from pg_database""")
</code></pre>

python ruby-on-rails