w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
Pagination with appengine ndb Cursor - python : Same cursor is being generated leading to repeatition of output results
It looks like you're using the get() method for both displaying a page and to handle an AJAX request. It's correctly generating a page with an initial cursor, but your $.ajax() method is expecting it to return JSON data. Split the page request and AJAX request into two methods. Try adding a post() method to your HomeHandler that returns JSON data like this: import json def post(self): q = Allnews.query().order(-Allnews.date_added) cursor = ndb.Cursor(urlsafe=self.request.get('cursor',default_value=None)) items, next_curs, more = q.fetch_page(30, start_cursor=cursor) if more: next_c = next_curs.urlsafe() else: next_c = None self.response.headers['Content-Type'] = 'application/json' self.response.out.write(json.dumps({'news': items, 'cursor

Categories : Python

Syntax error (1064) in MySQL statement in Python
A table name can not be parametrized. You have to add it in with string formatting. sql = """INSERT IGNORE INTO {t} (ID, A, B, C, D, E, F) VALUES (%s, %s, %s, %s, %s, %s, %s)""".format(t=table_name) rows_inserted += cursor.execute(sql, (1, row[0], row[1], row[2], row[3], row[4], row[5])) I'm not sure where this is documented, but you can see this to be true by trying: cursor = connection.cursor() sql = 'CREATE TABLE %s' cursor.execute(sql, ['test'])

Categories : Python

cursor.fetchall() vs list(cursor) in Python
list(cursor) works because a cursor is an iterable; you can also use cursor in a loop: for row in cursor: # ... A good database adapter implementation will fetch rows in batches from the server, saving on the memory footprint required as it will not need to hold the full result set in memory. cursor.fetchall() has to return the full list instead. There is little point in using list(cursor) over cursor.fetchall(); the end effect is then indeed the same, but you wasted an opportunity to stream results instead.

Categories : Python

Code inside SQL Cursor will only execute first FETCH
It looked ok to me but i obviously dont have your data to assist. Can I recommend putting a few print statements in various parts of your cursor. That way you can see how the code is actually flowing. It doesnt help but thats what I would do.

Categories : SQL

MySQLdb.cursors.Cursor.execute does not work
I have two queries, I execute them in the mysql console I can view the results. But I only see one query: import MySQLdb as mdb con = mdb.connect(hostname, username, password, dbname) cur = con.cursor() count = cur.execute(query) cur.close() con.close() My guess is query contains the both queries separated by a semin-colon and is an INSERT statement? You probably need to use executemany(). See Executing several SQL queries with MySQLdb On the other hand, if both of your queries are SELECT statements (you say "I see the result"), I'm not sure you can fetch both results from only one call to execute(). I would consider that as bad style, anyway.

Categories : Python

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')'
Your variable $city_id is null or an empty string ... (term_node.tid = $city_id) ... becomes this on the error message: ... (term_node.tid = ) ... which makes it an sql syntax error. You should change it to this: ... (term_node.tid = '{$city_id}') ...

Categories : PHP

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''leave''
Don't use single quaots You can try it as $result = mysql_query("select * from leave"); Or use ` key $result = mysql_query("select * from `leave`");

Categories : PHP

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 7
The problem is that you assumed the page request you received was using both GET and POST methods, which is impossible by the definition of the HTTP protocol. You used in your code something like "switch($_GET[...])" and immediately after that, you tried to get the values from the $_POST array, which will obviously be empty, since the request was using GET method. The workaround would be to replace all your "$_POST" occurences with "$_GET", but the real problem is that your assumptions were wrong. Either work with $_POST or with $_GET. If you want to make your page to be able to handle both POST and GET methods equally, you could replace all occurrences of $_POST and $_GET with $_REQUEST. Also, you have a lot of SQL injections in your code, which makes your code VERY insecure and ill-wri

Categories : PHP

ORA-00905: Trouble converting Mysql syntax to oracle syntax
You have to convert interval to add_months and sysdate() to sysdate. And you could also change to case to make it simple. SELECT SUM(T.SEND_UNREAD_DRAFT) SEND_UNREAD_DRAFT, SUM(T.SEND_READ_DRAFT) SEND_READ_DRAFT, SUM(T.SEND_APPROVED) SEND_APPROVED, SUM(T.SEND_COMPLETED) SEND_COMPLETED, SUM(T.SEND_FAILED) SEND_FAILED,SUM(T.RECEIVED_DRAFT) RECEIVED_DRAFT,SUM(T.RECEIVED_APPROVED) RECEIVED_APPROVED, Sum(T.Received_Accepted_Send) Received_Accepted_Send, Sum(T.Received_Rejected_Send) Received_Rejected_Send, Sum(T.Send_Canceled) Send_Canceled FROM( SELECT CASE WHEN TYPE = 'OUT' and STATUS = 'DRAFT' and READ_FLAG = 'N' THEN 1 ELSE 0 END SEND_UNREAD_DRAFT, CASE WHEN TYPE = 'OUT' and STATUS = 'DRAFT' and READ_FLAG = 'Y' THEN 1 ELSE 0 END SEND_READ_DRAFT, CASE WHEN TYPE = 'OUT' and STA

Categories : SQL

MySQL Cursor Loop - does not update, have read MySQL examples and Googled
If I understand correctly all you need is CROSS JOIN. Try INSERT INTO bullets (product_code, bullet_text) SELECT m.product_code, b.bullet_text FROM bullets b CROSS JOIN master m WHERE b.product_code = 10001 AND m.product_group = 3 AND m.product_code <> 10001; Here is SQLFiddle demo. Now you can wrap it up into a stored procedure if you went to CREATE PROCEDURE copy_bullets_test (IN product_code_from INT, IN product_group_to INT) INSERT INTO bullets (product_code, bullet_text) SELECT m.product_code, b.bullet_text FROM bullets b CROSS JOIN master m WHERE b.product_code = product_code_from AND m.product_group = product_group_to AND m.product_code <> product_code_from; And use it CALL copy_bullets_test(10001, 3); Here is SQLFiddle demo for that case.

Categories : Mysql

Python Abstract Syntax: Detect syntax error's'
No, you cannot, because after one syntax error the rest of the code structure is no longer recoverable. Take a missing parenthesis for example; was that a parenthesis that was missing, or a comma? Is the function call on the next line therefor part of the expression with the error, or not? If the comma was missing, there might be a parenthesis missing on the next line. If the parenthesis was missing, there might be a parenthesis too many on the next line. That'd be two very different syntax errors that depend on what the previous syntax error really was meant to be. A syntax error in one place invalidates the rest of the code and there is no point in continuing parsing, at least not for Python which needs to produce valid bytecode. You can use a Python linter; many can be integrated wi

Categories : Python

Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '
Your insert query is not valid sql. The keyword "set" is used with update queries. Insert queries look like this: insert into atable (f1, f2, etc) values (val1, val2, etc) or this insert into atable (f1, f2, etc) select val1, val2, etc from someOtherTables

Categories : PHP

MYSQL SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax
]. AS is not a SQL correct expression (it seems that you are using microsoft access to create your SQL) SELECT [BUSRUNDETAILS.busrundetailsid] as busrundetailsid, [BUSRUNDETAILS.BUSRUNID] as busrunid, round(BUSRUNDETAILS.Meterage,2) as max_meterage, BUSRUNDETAILS.StopNo as max_stopno FROM BUSRUNDETAILS INNER JOIN (SELECT r.BUSRUNID, max(R.STOPNO) As MAXSTOP FROM BUSRUNDETAILS AS R GROUP BY R.BUSRUNID) AS T2 ON (BUSRUNDETAILS.StopNo = T2.maxstop) AND (BUSRUNDETAILS.BusRunId = T2.BUSRUNID)

Categories : Mysql

Basic PHP syntax or config?; script doesn't execute on WAMP server
The opening tag for php does not look right: <? if($_POST['srSubmit'] && $_POST['srEmail'] && $_POST['srPass']) { should be: <?php if($_POST['srSubmit'] && $_POST['srEmail'] && $_POST['srPass']) {

Categories : PHP

While using Mysql cast function getting the Check Mysql version or the right syntax error
SELECT EM.rec_id AS rec_id,EM.employee_code, EM.employee_name, EM.designation, EM.weekly_off_day, EM.gender, EM.payment_type, SM.shift_name, PM.plant_name, EM.status AS status,EM.settlement_no, SCM.section_name FROM employee_master AS EM INNER JOIN shift_master AS SM ON EM.shift_rec_id = SM.rec_id INNER JOIN section_master AS SCM ON EM.section_rec_id = SCM.rec_id INNER JOIN plant_master AS PM ON EM.plant_rec_id = PM.rec_id ORDER BY CAST(EM.employee_code As UNSIGNED ) See this SO thread

Categories : Mysql

I am getting mysql error check the manual that corresponds to your MySQL server version for the right syntax to use near '?' at line 4
Try putting quotes around your question mark if it's the value in the database you're filtering by: $query_str = "SELECT cm.user_id, chat_message_content, u.firstname FROM chat_message cm JOIN user u ON cm.user_id = u.user_id WHERE cm.chat_id= '?'";

Categories : Mysql

mysql syntax error: mysql not allowing certain characters to be processed
Here is the working code with a bit of twist: $sql = mysql_connect("localhost", "root","root"); mysql_select_db("Tweet_Corpora"); if(!$sql){ die("could not connect: " . mysql_error()); } $file = fopen("/Applications/MAMP/bin/mamp/uploads/corpus/set_2.txt","r") or exit("Unable to open file!"); while(!feof($file)){ $string = fgets($file); $arr = (explode(" ", $string)); $idd= mysql_real_escape_string($arr[0]); $tweet=mysql_real_escape_string($arr[1]); $test = "INSERT INTO Display (tweet_id, raw_tweet) VALUES ('".$idd."','".$tweet."')"; $result = mysql_query($test); if(!$result){ die("could not load. " . mysql_error()); } }

Categories : Misc

php doesn't execute the query of mysql, but in mysql it's executable
Perhaps this should help: $strQry = "INSERT INTO resource (id_mission, name, ressource_path, assignment, position) SELECT ".$new_id_mis.", name, ressource_path, assignment, position FROM resource WHERE id_mission=".$id_mission; mysql_query($strQry);

Categories : PHP

Is there a way to tell Stata to execute the whole do-file ignoring the lines producing exceptions (or even syntax errors)?
(version 2) Wanting Stata to ignore mistakes can itself be mistaken. If there is a mistake early in a do-file, it usually has implications for what follows. Suppose you got Stata to work as you wish. How do you know whether Stata ignored something important or something trivial? If it ignored something trivial, that should be easy to fix. If it ignored something important, that was the wrong decision. Let's now be more constructive. The help for do tells you that there is a nostop option. You need to be very careful about how you use it, but it can help here. The context of do, nostop is precisely that of the OP. People had do-files, often expected to take a long time because of big datasets or lots of heavy computation, and set them going, historically "overnight" or "while yo

Categories : Misc

Is it Possible to declare Cursor within IF Condition in MySQL UDF
even I never used CURSOR so far in MySQL, But what I found is that , it is clearly mentioned on MySQL manual Cursor declarations must appear before handler declarations and after variable and condition declarations. if you want to use that cursor on some condition then you must use FETCH CURSOR syntax in IF condition below are some good tutorial which will describe the cursor in details: CURSOR in mySQL stored procedure MySQL CURSOR Tutorial

Categories : PHP

mysql row comparison cursor vs joins
Distance formula DELIMITER $$ DROP FUNCTION IF EXISTS `GetDistance`$$ CREATE FUNCTION `GetDistance`( lat1 numeric (9,6), lon1 numeric (9,6), lat2 numeric (9,6), lon2 numeric (9,6) ) RETURNS decimal (10,5) BEGIN DECLARE x decimal (20,10); DECLARE pi decimal (21,20); SET pi = 3.14159265358979323846; SET x = sin( lat1 * pi/180 ) * sin( lat2 * pi/180 ) + cos( lat1 *pi/180 ) * cos( lat2 * pi/180 ) * cos( abs ( (lon2 * pi/180) - (lon1 *pi/180) ) ); SET x = atan( ( sqrt( 1- power( x, 2 ) ) ) / x ); RETURN ( 1.852 * 60.0 * ((x/pi)*180) ) / 1.609344; END $$ DELIMITER ; I need to apply following points based on the distance 30 miles or less = 2 points 30 - 50 = 1 points 50 and up = 0 points

Categories : Mysql

MySQL cursor fetching same result twice
On the last iteration through the loop, the fetch is failing. When it does so, you are re-inserting the previous values. Here is one way to fix this: REPEAT FETCH CURSOR_NOVEDADES INTO vID; if ! vdone then SELECT CONCEPTO_ID, MONTO INTO vCONCEPTO_ID, vMONTO FROM NOVEDADES WHERE ID = vID; INSERT INTO LIQUIDACIONES_DETALLE (LIQUIDACION_ID, CONCEPTO_ID, MONTO) VALUES(pLIQUIDACION_ID, vCONCEPTO_ID, vMONTO); end UNTIL vDONE END REPEAT;

Categories : Mysql

Check when the cursor changed from arrow to hand cursor (link hand cursor)
As you haven't specified, I will assume you are using Win Forms. To capture the hover, simply subscribe to the OnMouseHover event, e.g. yourLinkLabel.MouseHover += yourLinkLabel_MouseHover; ... private void yourLinkLabel_MouseHover(object sender, EventArgs e) { MessageBox.Show("You are standing on link"); }

Categories : C#

Is there such mysql syntax to end/limit mysql query?
I will assume that you are using PHP and that 'client' is received as a parameter via $_POST from the user. In this scenario I think that what you want to do is prevent is SQL injection. If so you should solve it by using mysql_real_escape_string() to sanitize your input parameters: // This could be supplied by a user, for example $type = $POST['type']; // Formulate Query // This is the best way to perform an SQL query // For more examples, see mysql_real_escape_string() $query = sprintf("SELECT * FROM username WHERE type='%s', mysql_real_escape_string($type)); // Perform Query $result = mysql_query($query); ... I took this sample from the mysql-query reference and adapted it for your needs.

Categories : Mysql

cursor does not show date value in mysql procedure
i add DATE_FORMAT statement in select as DEClARE lease_cursor CURSOR FOR select ta.TAP_PROPERTY_ID,**DATE_FORMAT(ta.TAP_PROPOSED_START_DATE,'%Y-%m-%d'),DATE_FORMAT (ta.TAP_PROPOSED_END_DATE,'%Y-%m-%d')**,ta.TAP_RENT_TYPE, ad.AGR_CREATION_TS,ad.AGR_CREATED_BY,apd.APP_COM_ID from agreement_details ad,tenancy_applications ta,application_details apd where ad.AGR_APP_ID=ta.TAP_APP_ID and apd.APP_ID=ta.TAP_APP_ID;

Categories : Mysql

How to convert a SQL Server cursor to MySQL equivalent
The MySQL equivalent would be something like this: BEGIN DECLARE CurrentFirstName VARCHAR(300); DECLARE CurrentAge INT; DECLARE done INT DEFAULT FALSE; DECLARE CursorName CURSOR FOR SELECT FirstName, Age FROM Customers; DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; OPEN CursorName; myloop: LOOP FETCH CursorName INTO CurrentFirstName, CurrentAge; IF done THEN LEAVE myloop; END IF; IF CurrentAge > 60 THEN insert into ElderCustomers values (CurrentFirstName,CurrentAge); END IF; END LOOP; CLOSE CursorName; END; The big difference is in the loop, using the CONTINUE HANDLER to set a flag when there are no more rows to fetch, and exiting the loop when the flag is set. (That looks ugly, but that's the way it's done in MySQL.) T

Categories : Mysql

Mysql stored procedure error -- LOOP and CURSOR
That particular error is caused by fact that you didn't use SET statement to assign a value to a variable. Change oldID = NULL; to SET oldID = NULL;

Categories : Mysql

Save url containing special characters into mysql database using cursor
Column url can store shorder string as you try to insert (243 characters). Other URLs are shorter. To expand column use: ALTER TABLE maintable MODIFY COLUMN url VARCHAR(250)

Categories : Mysql

'select into' statement not working in mysql store procedure with cursor
To accomplish the same without cursor use (UPDATED): INSERT INTO request SELECT deliverable.deliverableId as delId, qwe.BuID as custId, qwe.BuprodName as prod FROM deliverable inner join (select tname, version, BuID,BuprodName from temprequest) as qwe (tname, version, BuID,BuprodName) on deliverable.Product_prodName = qwe.vtname AND deliverable.version = qwe.tversion I've just realised that BuID and BuprodName are constants here and not used anywhere besides insert statement.

Categories : Mysql

MySQL Connector/Python - insert python variable to MySQL table
just had the same issue. Are you using numpy? One of your passed values could be of type numpy.float64 which is not recognized by the mysql connector. Cast it to a genuine python float on populating the dict. This worked for me. hth, gr~~~

Categories : Python

Quoted separator cursor copy_from in python
Seems Like cursor.copy_from or copy_to does not support Quoted sheets. solution is to use copy_expert. import psycopg2 f_cm = open('cm.sql', 'r') constr = "dbname='mydb' user= 'pgsql' host='127.0.0.1'" db = psycopg2.connect(constr) st = db.cursor() copy = "COPY mytable(col1,col2, col3) FROM STDIN with csv" st.copy_expert(sql=copy, file=f_cm) db.commit() st.close() db.close()

Categories : Python

Python: Passing a cursor back from a class for a dbi instance
Based on what you'd like to do class create_db(object): def __init__(self): import psycopg2 as pq self.cn = pq.connect('dbname=mydb user=me') self.cr = self.cn.cursor() def execute(self, query, *args): results = self.cr.execute(query, args) return results now you can run something like cur.execute('SELECT * FROM table1 WHERE column = ?;', (42,)) I can't remember off the top of my head but I think you'll want to omit the ; at the end of your SQL statement.

Categories : Python

Python + MongoDB - Cursor iteration too slow - Unresolved?
I can't replicate - I'm loading 150k documents and converting to a list in ~0.5 > ~0.8 seconds. Here are the results of the timeit test script - in seconds for converting 150,000 documents from the database into a list. -------------------------------------------------- Default batch size 0.530369997025 -------------------------------------------------- Batch Size 1000 0.570069074631 -------------------------------------------------- Batch Size 10000 0.686305046082 Heres my test script: #!/usr/bin/env python import timeit def main(): """ Testing loading 150k documents in pymongo """ setup = """ import datetime from random import randint from pymongo import MongoClient connection = MongoClient() db = connection.test_load sample = db.sample if db.sample.count() < 1

Categories : Python

Python: Set Cursor in TextBox based upon Radiobox Selection
Try: if self.radioButton1.GetValue() == True: instead of if self.radioButton1.GetValue() == 'True': (The code you posted works as desired with this change) Of course you could also just put: if self.radioButton1.GetValue():

Categories : Python

MongoDB query/cursor repeating itself in Python and Pymongo
As pointed out, the issue was the typo after "import." It was creating two separate "connections" and thus running it twice through the cursor. import pymongo instead of.. import mongo

Categories : Python

postgres python server side cursor won't insert all the data
If the oldgroups column is in the form 1,3,6,7 this will work: insert into newTable (userid, groupid) select id, groupid from ( select id, regexp_split_to_table(olgroups, ',') as groupid from oldTable ) o where not exists ( select 1 from newTable where groupid = o.groupid ) and groupid < 10000000 But I suspect you want to check for the existence of both groupid and id: insert into newTable (userid, groupid) select id, groupid from ( select id, regexp_split_to_table(olgroups, ',') as groupid from oldTable ) o where not exists ( select 1 from newTable where groupid = o.groupid and id = o.id ) and groupid < 10000000 The regexp_split_to_table function will "explod

Categories : Python

Android cursor Error : Make sure the Cursor is initialized correctly before accessing data from it
The error message says Failed to read row 0, column 1 from a CursorWindow which has 0 rows, 4 columns. So your query is returning 0 rows. Your if statement should read: if(cur!=null){ // Best to manage any non-null cursor as then it will be closed when the // activity is stopped startManagingCursor(cur); // Only if a row was found if(cur.moveToFirst()) { Log.d("debug Cursor" , "can be created"); Log.d("KEY_PHOTO_HKID_HEX" , cur.getString(1)); Log.d("KEY_PHOTO_ADDRESS_HEX" , cur.getString(2)); Log.d("KEY_PHOTO_BANK_HEX" , cur.getString(3)); }else{ // Handle no rows returned } }else{ Log.d("debug Cursor" , "cannot be created"); }

Categories : Android

Android App crashing in Cursor Query (Image/Video Cursor)
Try this one trick Cursor cursor= getApplicationContext().getContentResolver().query( MediaStore.Images.Media.EXTERNAL_CONTENT_URI,columns, selection, selectionArgs, orderBy); if (cursor != null) { if (cursor.moveToFirst()) { ///// Put your idea here } cursor.close(); }

Categories : Android

Changing cursor position using arrow cursor keycode in javascript
I guess the reason is, all other characters are from keys that have some character associated with it. But arrow keys do not have ←,→ such characters associated with them. They just have some functions. Have you ever used arrow keys to input an arrow in a text box? If you really want to use them to input arrows, you can do the following in your jQuery.. var element = $('#myeditor'), elementText = element.text(); store = { 37: "&larr;", 38: "&uarr;", 39: "&rarr;", 40: "&darr;" }; element.keydown(function( event ) { var selection = window.getSelection().getRangeAt(0); //getSelection gets the selected range of text, when nothing is selected,selection is empty.getRangeAt(0)makes selection from the start of s

Categories : Javascript

How to change the cursor type to be like Excel grid cursor?
i guess i'll answer the question, since nobody else will. i have a function that fixes some of Delphi's built-in cursors (to use the standard Windows cursors). But i also use it to add some new custom cursors. i'll trim down my function to only add two new cursors: crColorPicker: (a color picker cursor) crExcelCross: (an Excel cross cursor) First i needed to create an ExcelCross.cur in Visual Studio: Now create a new resource script file, wumpa.rc, where i will specify my two cursor files: wumpa.rc ColorPicker CURSOR "ColorPicker.cur" ExcelCross CURSOR "ExcelCross.cur" And add that wumpa.rc file to my project using Project -> Add to project. Now i declare two global constants to represent my new cursors. Like crHourGlass, or crNo, we will now have crColorPicker an

Categories : Delphi



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.