Questions tagged [python]

Python is a powerful and ubiquitous language. When using a Python variant or library (e.g. Pandas, SQLAlchemy, pg8000, psycopg2), please include it in the tags. Questions using this tag should restrict themselves to interactions directly with the database tier. General python scripting questions should be directed to [StackOverflow](https://stackoverflow.com/questions/tagged/python)

56 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
4
votes
1answer
630 views

Flask mongodb assertion 13 not authorized for query on flask_session.sessions

Need help resetting mongodb back to its original state. We have a flask app running with mongodb with authentication turned off. Running on Ubuntu with std Flask. We tried ALL sorts of combinations ...
3
votes
0answers
103 views

TCP Resets when using psycopg2

I'm trying to do a simple health check for keepalived and other services via a python script and psycopg2 library. All seems to be alright, until I close the connection, at which point a packet with ...
3
votes
1answer
902 views

select two tables and print the columns side by side with matching key in hive

I have the below tables: table_1 name_1 id_1 value_1 avi 1 21 adi 2 X table_2 name_2 id_2 value_2 avi 1 21 adi 2 22 metadata_info: can be read from ...
2
votes
1answer
299 views

Have several 128 elements lists, need to obtain distance between them

Is storing them in a CUBE type field and then getting euclidean distance, (using <->) the only way? I can not save them as a list of floats, since i get: "can't adapt type numpyndarray" Can ...
2
votes
0answers
612 views

Redis along with Mysql

I'm currently working on a mobile app alike Google Maps or Wave, but also including parking. The application its running with MySQL primarily. With at this stage most of our data is loaded by python ...
2
votes
0answers
726 views

MongoDB communication issues on Azure

I have a Python uWSGI app running behind Nginx using pymongo to communicate with a 4 machine replica set running Mongodb 2.6.3. The replica set is configured using domain names for each machine mdb-0[...
1
vote
0answers
167 views

operand should contain 1 column Use Variables in SQL statement in Python

Trying to insert four columns and multiple rows with variables. The table in mysql has 8 columns in total. Four columns to insert is as following: report_type= tuple(("ada","asda","frfe","adaaa","...
1
vote
0answers
16 views

Custom Export from power BI service

I'm trying to make a custom button that exports filtered tables to a csv and downloads them to my computer. I am aware that you can do this with the '...' button but this functionality is for other ...
1
vote
0answers
63 views

Designing a table with precalculated team values for fast read queries

My version of PostgreSQL is 10.7. As it's something I can't calculate on the fly due to the amount of times it might be used, I decided to store all the 11 million combinations and their result on a ...
1
vote
1answer
124 views

No output when use pymongo watch()

I try to access real-time data changes with pymongo.mongo_client.MongoClient.watch(), code example (Python 3.5.3, pymongo==3.7.2): from pymongo import MongoClient DB_CON_STR = "mongodb://10.10.10....
1
vote
0answers
266 views

PGPool II + Django w/ psycopg2 load balancing

I've a pool of applications running django 1.6 with psycopg2 on top of a PGPool II with two backends PostgreSQL servers. But all queries (read and/or write) are going to master PostgreSQL even SELECT. ...
1
vote
0answers
151 views

Cassandra pool warning displaying continuously

I am using the Cassandra driver for python in Spyder. I am trying to fetch some data from Cassandra table. Here is my code: from cassandra.cluster import Cluster cluster=Cluster(['some_ip']) session=...
1
vote
0answers
65 views

MySQL Shell Python Client library

Is there a python client library available to interact with MySQL Admin API and to do similar stuff that MySQL Shell does. From the documentation of MySQL Shell, I could see that there is a --py mode ...
1
vote
0answers
192 views

PID from pg_backend_pid () does not exist in pg_stat_activity

I have a software written in Python which accesses a postgres database. In order to allow several instances of the software, on one of the screens I need what is the connection identity so I check the ...
1
vote
0answers
175 views

Multiple many-to-many database relations

SO told me to ask here, so this is just copy-pasted from over there We're making a database of anime. Every anime can be listed as having been made by an arbitrary number of studios, and every studio ...
1
vote
1answer
232 views

Alter postgres password from python?

When I run this query from psql shell everything works fine: ALTER ROLE postgres WITH ENCRYPTED PASSWORD 'somePassword'; but when I try exactly the same query from python (with psycopg2 package) ...
1
vote
0answers
129 views

barman + corrupted wall + how it can be

I am using barman for bsackup version 2-1.1 and restore postgresql first after 2 restore that was successfully I perform some show-backup on other backup , and I notices all backup return this ...
1
vote
1answer
1k views

Connecting client application to MariaDB Galera cluster

I currently have a REST API written in Flask that connects to a MariaDB server. I'm thinking about replacing the server with a Galera cluster to improve availability and ensure continuity in case one ...
1
vote
0answers
49 views

Create Database within the same Cluster without closing active connection?

Is there a way to clone a master database without closing an active connection? I have a single master database and multiple slave database. To clone a new database I use the following command ...
1
vote
0answers
496 views

Import Data From csv Into Postgresql WITHOUT COPY

I am writing a function for a python environment which needs to import data from a csv file into an existing table. The scope in which the function can execute does not allow for a db SUPERUSER to run ...
1
vote
0answers
916 views

postgresql Idle for transaction while migrating 30GB database

I'm migrating part of a mysql database into a postgresql database with a different Schema. I've written a python script, using mysql-connector and psycopg2 modules. It takes care(should) to convert/...
1
vote
0answers
32 views

Heirarchial Database with Time Tracking

Working in Python/Django 1.8 I have a problem along the following lines: Assembly Table |Part |Parent (FK to other Part) i.e.: Car |--Tire |--Bolt A |--Bolt B Journey Table |Date |...
1
vote
0answers
25 views

Adding new stored procedure to the exisiting database using connectors?

The project I'm currently working on is mostly pythonic, by this reason I'll likely use mysqldb python connector or sqlalchemy. The question arose when I've tried to find out the way of adding new ...
1
vote
0answers
2k views

Creating Pandas DataFrame on Python From a MongoDB Document containing Embedded documents

I am working on a machine learning algorithm on python's scikit.learn, but this time the data are in Mongodb documents format. I would like to pull my data into a dataframe. Here is an exemple of the ...
1
vote
0answers
803 views

Migrate from SQLite to MySQL (then back)

For various reasons, I must use a SQLite database with a local application. However, I wrote a Flask app that enables users to more easily classify items in the database, and it runs very slow on ...
1
vote
0answers
161 views

Trouble adding foreign key on lots of data in Postgres

Working with PostgreSQL 9.0.8 on linux. Can't add foreign key. I have two tables: Table1 and Table2. Table1 has 10 columns and 200 000 rows filled with some data, where first column is 'id' (primary ...
1
vote
0answers
711 views

Does a high CPU usage -say 98%- necessary mean the database will be slower?

I have 4 python scripts each running in their own virtual machine. The scripts are accessing a central postgresql database. All scripts are reading from the same table but posting to different tables ...
0
votes
0answers
16 views

Populate mysql db to Shotgun server using Python

I've an internal mysql database. On each creation, modification or deletion of the content of this db, I need to run a python script to replicate those information into another software web server. ...
0
votes
0answers
53 views

Error: duplicate key value violates unique constraint, but the column does not have a unique constraint? postgreSQL

By the way, I'm trying to automate the below using python, but I've isolated the SQL code and tried it by itself on pgAdmin III, and it still doesn't work. So I have a table called tableName, and I ...
0
votes
3answers
17 views

Overwriting MySQL database to only store 1 month of data

We are logging data on hardware with only small memory (short on disk storage) only 4GB. We only require the data to be stored for 1 month and then be over written in a way that it overrides older ...
0
votes
0answers
111 views

SSHtunnelForwarder to Linux Box, then connect to Postgres RDS (AWS)

I'm trying to write a python script to update DDL in a Aurora RDS (postgres) on AWS. In Order to do this, I need to SSHTunnel to a linux box that sits at the edge of the VPC, then do another jump to ...
0
votes
0answers
17 views

Neo4j: Connection closed after few minutes: defunct connection Address (Python)

I have a server (hosted in Azure) in which the connection is opened (python): self._driver: Driver = GraphDatabase.driver(credentials["uri"], auth=(credentials["user"], credentials["password"]), ...
0
votes
1answer
100 views

CSV (UTF-8) to Postgres database (UTF-8), doesn't show äöå characters

I have csv-file that is UTF-8 encoded. I'm using python (psycopg2) to copy it into a Postgres database. My Postgres database is using UTF-8. However I have problems to show Ä, Ö and Å characters. If ...
0
votes
0answers
18 views

How to increase idle time of “LaunchPad” for SQL Server external scripts?

sp_execute_external_script can take a while to initialize when not run for a short time. How do I set the idle time on the controller Launchpad process to keep it from shutting down too soon? Note I ...
0
votes
1answer
594 views

Psycopg2 Errors on SQL statement when trying to copy data from CSV file into PostgreSQL database

I am not a developer or PostgreSQL DB admin, so this may be basic questions. Logistics: Windows 10 server / pgAdmin 4 / Postgres 10 / Python 2.7.13 I'm using a python script to ingest external data, ...
0
votes
0answers
16 views

Reconstruct folder hierarchy in JSON format from MySQL using Python

I have a table with a structure like this: | itemID | parentFolderID | folderName 1 0 folderA 2 1 folderB 3 1 ...
0
votes
0answers
88 views

which python version is required to install plpython3u of which postgresql version?

I want to know if there is a reference table or trick to find out which python version is required by plpython3u of which version of postgresql . example python 3.4 is required for plpython3u of ...
0
votes
0answers
22 views

Changing Cube Max Dimension

thanks in advance for any help. Python/postgres noob here. I need to change the default dimension for cubes in postgres. I tried to download source code, fixing the cubedata.h file to change max ...
0
votes
0answers
426 views

psycopg2.pool.PoolError: trying to put unkeyed connection

I'm trying to get connection pooling to work in my Python Flask web application. The code I am using is as follows: from contextlib import contextmanager import logging from psycopg2 import pool, ...
0
votes
1answer
247 views

Find and Insert Missing data in Mongodb Collection

I want to write python3 code to check and insert missing data. My MongoDB collection documents have one field named "height" which is BTC block number. I want to traverse in a range start to the ...
0
votes
1answer
1k views

Query using $gte and New Date() working in MongoDB shell but not through python pymongo

When I run the following in the mongodb shell, it returns the correct number of records: (searching for the matching "SourceName" within the last 8 days) mongos> db.fdl.count({ SourceName : "SRC1"...
0
votes
1answer
398 views

get row/value by primary key number

I'm writing my own python wrapper on top of official mysqldb connector. I'm trying to design method that would dynamically extract row data knowing KEY ID. SELECT * FROM cameras; +----------+--------...
0
votes
1answer
71 views

MySQL 'generator' not closing connections

I have the following function which is leaving connections open but I can't figure out why. The Cursor class creates a python-generator type function, allowing me to iterate over millions of rows. ...
0
votes
1answer
55 views

How to perform multiple selects without using for loop

I am querying for ids using a for-loop. So multiple selects are being used. Is there a better way to do this to have a single select statement for all ids? for id in aoi_ids: sql = """SELECT id, ...
0
votes
1answer
265 views

Use of MySQL trigger to insert row's week number

I have a table of orders in a MariaDB database that currently has a datetime column. For the dashboard I am building for this database, I have a statistic I would like to display which is "Orders This ...
0
votes
1answer
99 views

InnoDB Concurrent writes being ignored

Sorry if this isn't the right place, this is my first time posting anything here. Anyway, I know I'm not supposed to but I can think of no other way. I need to use a small MySQL table (70 rows x 6 ...
0
votes
1answer
13 views

Am fetching data from database i need to pass variable in my query.but am not getting how to pass variable in query

import MySQLdb as mdb con=mdb.connect(host="localhost",user="root", passwd="yogi@123", db="wisdomjo_db2011") cur=con.cursor() cur.execute("SELECT suggestion,related FROM `auto_related` WHERE ...
0
votes
1answer
45 views

Booleans, CONSTANTS or mapping table for 'status'-like fields?

I am modelling a User table which needs to have the following information about the users: is_active? is_detained? has_voluntarily_deactivated? is_temporarily_suspended? and so on... Basically, ...
0
votes
0answers
2k views

psycopg2 - drawbacks of reusing cursors?

I am new to Python and the psycopg2 module. context Working on a script that select data from MySQL, perform some operations (conversion of data-types and other "transformations"), and finally ...
0
votes
0answers
218 views

PostgreSQL becomes very slow after heavy utilization

I have built a Python web application and I am hosting it in a 2GB RAM Debian Server. My application uses PostgeSQL 9.1 with PostGIS. One of my tasks involves importing data from big csv files. ...