Tagged Questions
0
votes
0answers
4 views
Using NTEXT with MySQLdb for Python
What is the correct way to use NTEXT with MySQLdb for Python?
I have a create table command that keeps throwing an error saying that there's an error near NTEXT and according to W3C NTEXT is the ...
0
votes
0answers
29 views
Django equivalent of join on self join?
I've got a pair of tables in a mysql database:
CREATE TABLE `assets` (
`idasset` varchar(255) NOT NULL,
`guid` varchar(36) DEFAULT NULL,
`type` varchar(64) DEFAULT 'unknown',
PRIMARY KEY ...
1
vote
1answer
14 views
SQLAlchemy commits makes float to be rounded
I have a schema with a Float column, something like this:
Base = declarative_base()
class Table(Base):
__tablename__ = 'table'
id = Column(Integer,primary_key=True)
amount = ...
0
votes
2answers
24 views
load data infile with many files
I have to load and append data in a mysql table from many files.
Files are stored in a same directory.
To load data from a single file I use:
load data local infile 'D:\\MyDir\\file.DAT' into table ...
0
votes
0answers
16 views
Functions on foreign keys in peewee
I'm trying to run an aggregation function on a foreign key in Peewee, but can't get it to work. I'm using MySQL server. I'm running into problems apparently because I'm using a "linking table".
For ...
1
vote
1answer
10 views
Pymysql Insert Into not working
I'm running this from PyDev in Eclipse...
import pymysql
conn = pymysql.connect(host='localhost', port=3306, user='bbos', passwd='bbos', db='fan')
cur = conn.cursor()
print "writing to db"
...
0
votes
1answer
11 views
SQLite Insert command in Python script Doesn't work on web
I'm trying to use an SQLite insert operation in a python script, it works when I execute it manually on the command line but when I try to access it on the web it won't insert it in the database. Here ...
-1
votes
1answer
35 views
Best way to approach storing information across mutliple servers [on hold]
I'll try my best to explain what I need to do, but if anything needs clarifying please let me know.
Basically I have a python script I run on 5 different servers and they perform tasks based on ...
0
votes
1answer
31 views
How to query a MySQL database via python using peewee/mysqldb?
I'm creating an iOS client for App.net and I'm attempting to setup a push notification server. Currently my app can add a user's App.net account id (a string of numbers) and a APNS device token to a ...
0
votes
0answers
7 views
using external_acl_type in squid 3.3.8
Am using Squid 3.3.8 and I need to check clients ip/mac from Mysql. I heard about external_acl_types and wrote a little python script. This script takes one argument [ip/mac] and checks it with mysql ...
0
votes
2answers
21 views
MySQLdb Python insert %d and %s
Precursor:
MySQL Table created via:
CREATE TABLE table(Id INT PRIMARY KEY NOT NULL, Param1 VARCHAR(50))
Function:
.execute("INSERT INTO table VALUES(%d,%s)", (int(id), string)
Output:
...
1
vote
1answer
32 views
How to write multi column in clause with sqlalchemy
Please suggest is there way to write query multi-column in clause using SQLAlchemy?
Here is example of the actual query:
SELECT url FROM pages WHERE (url_crc, url) IN ((2752937066, ...
0
votes
1answer
10 views
Why tornado removed database after v3.0
what is the reason that database module is removed? Just because the database module is not async?
Any one could give me the detail and what is the best way of using python to connect mysql?
0
votes
0answers
19 views
Python timer with interrupts on Windows?
I want to be able to execute a MySQL query using the MySQL connector, but have it kill the query after a specified amount of time. However, if the query is done executing, it should shut off the timer ...
0
votes
1answer
34 views
Finding Locations with n Miles of Existing Locations [on hold]
Problem
I have a list of ~5000 locations with latitude and longitude coordinates called A, and a separate subset of this list called B. I want to find all locations from A that are within n miles of ...
0
votes
1answer
28 views
Best way to handle a database with lots of dynamically added columns?
I'm using a python script to run hourly scrapes of a website that publishes the most popular hashtags for a social media platform. They're to be stored in a database (MYSQL), with each row being a ...
-1
votes
2answers
28 views
How to properly store a list of data in SQL?
I'm still wrapping my head around some basic concepts of SQL. More so I'm trying to understand how I'd manage of list of data in a row. There's a possibility it'll be different lengths of names so I ...
1
vote
1answer
36 views
How to write Django model to get record from multiple tables?
class Game(models.Model):
total_players = models.IntegerField(max_length=10)
created_on = models.DateTimeField(auto_now_add=True)
updated_on = models.DateTimeField(auto_now=True)
class ...
1
vote
2answers
33 views
SQL datatbase not accepting UTF -8 Characters [duplicate]
I have a python program wherein I access a url and extract data. I then input this data into a mysql table. The mysql table has columns pid ,position,club, points,s,availability, rating,name . I have ...
0
votes
1answer
19 views
Python: Proper way to store list of strings in sqlite3 or mysql
I'm trying to store a list of string values into a sql database.
list = ['please','help','me']
I've tried converting to unicode and using the array.array('u',list)
unicode_list = unicode(list)
...
0
votes
0answers
31 views
Chinese character encoding issue when adding Scrapy for Python items into MYSQL
I'm trying to get scraped Chinese text into a MYSQL database from python scrapy, but it seems that either scrapy or MYSQL can't handle Chinese characters using my current method.
def ...
0
votes
0answers
21 views
Using sqlite to access a database online [on hold]
So in my class we have databases set up online via phpMyAdmin that we're supposed to populate. I've written a Python script that scraped all the data I wanted off the internet and was wondering if it ...
1
vote
0answers
30 views
Python MySQLdb loop
Here is the pseudo code I am trying to achieve;
connect to db
While True:
execute query (SELECT * FROM requests WHERE state = 'NOT_STARTED'
foreach row in rows
#process each row
Here is the code ...
0
votes
2answers
29 views
Python - writing out the result of Popen into a mysql table
Is it possible to write every line, I receive from this script, into a mysql table ? I want to have 2 columns: The ip-adress I need for the command (ipAdresse) and a part of the output of the command ...
1
vote
1answer
32 views
scrapy exceptions.TypeError: 'int' object has no attribute '__getitem__'
When I was in use scrapy collection into Mysql and the have some problems, hope everyone to give solutions, thank you。
pipelines.py type of error:
2013-12-06 18:07:02+0800 [-] ERROR: Unhandled error ...
0
votes
1answer
15 views
How to find the newest entry for each of “n” with sqlalchemy
I'm working on fixing up a forum script of mine, and I want to do what many popular sofwares do and display the latest reply for each board category on the category list.
I just can't seem to get ...
0
votes
0answers
9 views
PySQLPool and Celery, proper way to use it?
I am wondering what is the proper way to use the mysql pool with celery tasks.
At the moment, this is how (the relevant portion) of my tasks module looks like:
from start import celery
import ...
1
vote
2answers
33 views
How to store empty value as an Integerfield
I've seen all the similar threads, read the docs, and tried many combinations to store an empty value as IntegerField in db and failed every single time.
I am using MySQL.
My models.py defines an ...
-1
votes
0answers
29 views
Set Django mysql database to display non-latin characters, such as greek
I have a problem setting mysql db to properly recognise greek characters in django. in my setting.py file I have included the following options:
'OPTIONS': {
'charset': 'utf8',
...
0
votes
2answers
39 views
Generate multiple strings in overage (1000)
I have some trouble with rows generation for mysql in django project!
I need to generate 1000 unique rows in a table, looked like :
id(int) - auto
title(varchar)
description (text)
Any ideas?
Thanks ...
0
votes
1answer
38 views
DatabaseError: (1071, 'Specified key was too long; max key length is 767 bytes')
I have a django project and I would like to run some unit tests. When I try:
python manage.py test it throws this error and I couldn't find much information about it in here.
my db settings in ...
0
votes
1answer
33 views
Django Multiple Result Sets
I have a stored procedure that i'm calling with cursor.execute in my Django app. The stored procedure returns 2 result sets but I can't seem to access the second one via Django. What is the proper way ...
-5
votes
0answers
33 views
How to get data of two tables python django? [closed]
pedidos_bd = Pedido.objects.filter(id=4255, pedidoitem__pedido=4255)
for pedido in pedidos_bd:
temp = u"{0};{1};{2}".format(
pedido.data,
pedido.fechamento,
...
0
votes
0answers
40 views
python : Unknown MySQL server host '192.12xx.xxx.xxx
I'm in new to python. I can't connect remote server mysql using python.
first.py
#!/usr/bin/python
import MySQLdb
import second
DBHostname = second.hostname
DBuser = second.user
DBPWD = ...
0
votes
1answer
22 views
query url from mysql database using Python
I am trying to query a URL address from mysql database so that I can connect using this address and scrape a website.
however I get an error
Code:
cnx = mysql.connector.connect(host=mysql_host, ...
0
votes
1answer
15 views
CRC 32 Mysql and CRC32 python?
i don't known ? help me
In mysql i run :
SELECT CRC32('test');
result = 3632233996
In python :
import zlib
print zlib.crc32('test')
result = -662733300
please help me!
0
votes
1answer
29 views
SQLalchemy: changes not committing to db (solved)
I am trying to write what should be a relatively simple script using SQLalchemy to interact with a MySQL database. I am pretty new to sqlalchemy, and programming in general, so I am in need of help.
...
1
vote
1answer
40 views
Web2Py DAL, left join and operator precedence
In my DB, I've basically 3 tables:
usergroup(id, name, deleted)
usergroup_presentation(id, groupid, presentationid)
presentation(id, name)
I'm trying to run this DAL query:
left_join = ...
1
vote
1answer
53 views
pytz and Centos and mysql - django
The admin view of blog objects lists blog objects sorted by date. When the page is open (on development server), this error is returned:
Database returned an invalid value in QuerySet.dates(). Are ...
0
votes
1answer
22 views
Django querying a nested list of times Django 1.2
I have a list of objects which form a tree structure through foreign key relationships.
parent = models.ForeignKey( 'Category', related_name = 'child_set', null = True )
So each category object has ...
0
votes
1answer
20 views
Celery and mysql connections
What is the appropriate way to handle mysql connections when multiple celery tasks read and write to the same database?
Pooling ? If so, is there support for it in mysqldb for python?
Thank you
1
vote
1answer
27 views
how to convert from MySQL datetime to numpy datetime64?
I am loading a cursor into a numpy array as a precursor to using pyplot.
I have not been successful in converting the datetime field from Mysql into the datetime64 that numpy uses.
Python code
...
0
votes
2answers
37 views
Compare two databases and find common value in a row
I have two databases (infact two database dump ... db1.sql and db2.sql)
both database have only 1 table in each.
in each table there are few columns (not equal number nor type) but 1 or 2 columns ...
0
votes
0answers
23 views
gevent and SQLAlchemy MySQL compatible driver [closed]
I'm working on a project which relies on gevent for concurrency and needs to work with a MySQL DB. I would like to use SQLAlchemy although I have to say it is not a strict requirement. Using a MySQL ...
0
votes
1answer
31 views
Is it possible to run scripts on django using only ftp?
I am newbie to python and django, but this time I need a fast solution. I've got a problems, using hosting where my django application is deployed so I need to migrate to another server, but I have no ...
0
votes
1answer
52 views
Exception Value: 'DatabaseWrapper' object has no attribute 'Database'
I looked at the similar posts before entering this question. I am using Django 1.5, Python 3.3.2, and MySQL 5.6 / Connector.
I am new to Django/Python and working my way through basic tutorial. I ...
1
vote
1answer
21 views
Optimize order by random() in table with lot of records
I am using SQLAlchemy to fetch one random result (from count results I choose only one based on some stuffs/ this cannot be on sql level choosing) which satisfies conditions, my query looks like
for ...
0
votes
2answers
30 views
Can't get MySQLDb to work in python on Mac is there other easier DB?
I am looking for a production database to use with python/django for web development. I've installed MySQL successfully. I believe the python connector is not working and I don't know how to make it ...
1
vote
3answers
5k views
using Mysql and SqlAlchemy in Pyramid Framework
Pyramid Framework comes with a sample tutorial of sql alchemy that uses sqlite. The problem is that i want to use mysql so i change this
sqlalchemy.url = sqlite:///%(here)s/tutorial.db
Into this
...
24
votes
4answers
26k views
Inserting a python datetime.datetime object into mysql
I have a date column in a mysql table. I want to insert a datetime.datetime() object into this column. What should i be using in the execute statement?
I have tried:
now = datetime.datetime(2009,5,5)
...